]> granicus.if.org Git - vim/commitdiff
patch 8.0.1837: one character cmdline abbreviation not triggered after '<,'> v8.0.1837
authorBram Moolenaar <Bram@vim.org>
Sun, 13 May 2018 16:36:27 +0000 (18:36 +0200)
committerBram Moolenaar <Bram@vim.org>
Sun, 13 May 2018 16:36:27 +0000 (18:36 +0200)
Problem:    One character cmdline abbreviation not triggered after '<,'>.
Solution:   Skip over the special range. (Christian Brabandt, closes #2320)

src/ex_getln.c
src/testdir/test_mapping.vim
src/version.c

index 0124098da5195cee19989b4bd25e327519b9b47c..acaaef4705bf6f86781a65cd476d079c343df63e 100644 (file)
@@ -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)
index 79863c4da91b5fbea8eb02f650f5c3107d8d1983..fd7e28f79886899ceb7b0f597c9a882cae800cf4 100644 (file)
@@ -214,3 +214,19 @@ func Test_abbreviation_CR()
   delfunc Eatchar
   bw!
 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
index feffa38f23f7f00386ea52b963ceb3098b8b7bd0..80121576eaafb8560af6978aef8afd4e178fa178 100644 (file)
@@ -761,6 +761,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1837,
 /**/
     1836,
 /**/