From: Bram Moolenaar Date: Sun, 13 May 2018 16:36:27 +0000 (+0200) Subject: patch 8.0.1837: one character cmdline abbreviation not triggered after '<,'> X-Git-Tag: v8.0.1837 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5e3423d192bfa502c6704f731fa2ec6821f9a2f0;p=vim patch 8.0.1837: one character cmdline abbreviation not triggered after '<,'> Problem: One character cmdline abbreviation not triggered after '<,'>. Solution: Skip over the special range. (Christian Brabandt, closes #2320) --- diff --git a/src/ex_getln.c b/src/ex_getln.c index 0124098da..acaaef470 100644 --- a/src/ex_getln.c +++ b/src/ex_getln.c @@ -3572,10 +3572,25 @@ gotocmdline(int clr) static int ccheck_abbr(int c) { + int spos = 0; + if (p_paste || no_abbr) /* no abbreviations or in paste mode */ return FALSE; - return check_abbr(c, ccline.cmdbuff, ccline.cmdpos, 0); + /* Do not consider '<,'> be part of the mapping, skip leading whitespace. + * Actually accepts any mark. */ + while (VIM_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); } #if defined(FEAT_CMDL_COMPL) || defined(PROTO) diff --git a/src/testdir/test_mapping.vim b/src/testdir/test_mapping.vim index 79863c4da..fd7e28f79 100644 --- a/src/testdir/test_mapping.vim +++ b/src/testdir/test_mapping.vim @@ -214,3 +214,19 @@ func Test_abbreviation_CR() delfunc Eatchar bw! endfunc + +func Test_cabbr_visual_mode() + cabbr s su + call feedkeys(":s \\"\", 'itx') + call assert_equal('"su ', getreg(':')) + call feedkeys(":'<,'>s \\"\", 'itx') + let expected = '"'. "'<,'>su " + call assert_equal(expected, getreg(':')) + call feedkeys(": '<,'>s \\"\", 'itx') + let expected = '" '. "'<,'>su " + call assert_equal(expected, getreg(':')) + call feedkeys(":'a,'bs \\"\", 'itx') + let expected = '"'. "'a,'bsu " + call assert_equal(expected, getreg(':')) + cunabbr s +endfunc diff --git a/src/version.c b/src/version.c index feffa38f2..80121576e 100644 --- a/src/version.c +++ b/src/version.c @@ -761,6 +761,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1837, /**/ 1836, /**/