Merge #9106 from janlazo/vim-8.0.1837

vim-patch:8.0.1837
This commit is contained in:
Justin M. Keyes 2018-10-11 08:58:43 +02:00 committed by GitHub
commit 384770556b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 3 deletions

View File

@ -3522,10 +3522,28 @@ void gotocmdline(int clr)
*/
static int ccheck_abbr(int c)
{
if (p_paste || no_abbr) /* no abbreviations or in paste mode */
return FALSE;
int spos = 0;
return check_abbr(c, ccline.cmdbuff, ccline.cmdpos, 0);
if (p_paste || no_abbr) { // no abbreviations or in paste mode
return false;
}
// Do not consider '<,'> be part of the mapping, skip leading whitespace.
// Actually accepts any mark.
while (ascii_iswhite(ccline.cmdbuff[spos]) && spos < ccline.cmdlen) {
spos++;
}
if (ccline.cmdlen - spos > 5
&& ccline.cmdbuff[spos] == '\''
&& ccline.cmdbuff[spos + 2] == ','
&& ccline.cmdbuff[spos + 3] == '\'') {
spos += 5;
} else {
// check abbreviation from the beginning of the commandline
spos = 0;
}
return check_abbr(c, ccline.cmdbuff, ccline.cmdpos, spos);
}
static int sort_func_compare(const void *s1, const void *s2)

View File

@ -198,3 +198,19 @@ func Test_map_timeout()
set timeoutlen&
delfunc ExitInsert
endfunc
func Test_cabbr_visual_mode()
cabbr s su
call feedkeys(":s \<c-B>\"\<CR>", 'itx')
call assert_equal('"su ', getreg(':'))
call feedkeys(":'<,'>s \<c-B>\"\<CR>", 'itx')
let expected = '"'. "'<,'>su "
call assert_equal(expected, getreg(':'))
call feedkeys(": '<,'>s \<c-B>\"\<CR>", 'itx')
let expected = '" '. "'<,'>su "
call assert_equal(expected, getreg(':'))
call feedkeys(":'a,'bs \<c-B>\"\<CR>", 'itx')
let expected = '"'. "'a,'bsu "
call assert_equal(expected, getreg(':'))
cunabbr s
endfunc