]> granicus.if.org Git - vim/commitdiff
patch 8.0.0423: changing 'cinoptions' does not always work v8.0.0423
authorBram Moolenaar <Bram@vim.org>
Sun, 5 Mar 2017 18:44:06 +0000 (19:44 +0100)
committerBram Moolenaar <Bram@vim.org>
Sun, 5 Mar 2017 18:44:06 +0000 (19:44 +0100)
Problem:    The effect of adding "#" to 'cinoptions' is not always removed.
            (David Briscoe)
Solution:   Reset b_ind_hash_comment. (Christian Brabandt, closes #1475)

src/Makefile
src/misc1.c
src/testdir/Make_all.mak
src/testdir/test3.in
src/testdir/test_cindent.vim [new file with mode: 0644]
src/version.c

index 6e7fdde3c77a91cf15cf3eaabfc2d4d467bb2755..f9453229aaffd4068b03b59fe7850d718af67eeb 100644 (file)
@@ -2104,6 +2104,7 @@ test_arglist \
        test_channel \
        test_charsearch \
        test_changedtick \
+       test_cindent \
        test_cmdline \
        test_command_count \
        test_crypt \
index dce912c40690adcad9e7dc8784a5f5fb60f0da0c..ec92f037574716a5a902a4c5f4a803581825b430 100644 (file)
@@ -6974,6 +6974,9 @@ parse_cino(buf_T *buf)
      * while(). */
     buf->b_ind_if_for_while = 0;
 
+    /* indentation for # comments */
+    buf->b_ind_hash_comment = 0;
+
     for (p = buf->b_p_cino; *p; )
     {
        l = p++;
index e1ce1518fcb026bfdfaeeef3851d361ae3afa2cf..b7fb15caf6779859ebd2c94562f3c27151b6f08b 100644 (file)
@@ -143,6 +143,7 @@ NEW_TESTS = test_arabic.res \
            test_cdo.res \
            test_channel.res \
            test_charsearch.res \
+           test_cindent.res \
            test_cmdline.res \
            test_command_count.res \
            test_crypt.res \
index e8648d382ce216b7566e3c96f905f73660c887f7..9e66436e7dd4f24badfc4e7fa8808e5b57a3cb01 100644 (file)
@@ -1,6 +1,7 @@
 /* vim: set cin ts=4 sw=4 : */
 
-Test for 'cindent'
+Test for 'cindent'.
+For new tests, consider putting them in test_cindent.vim.
 
 STARTTEST
 :so small.vim
diff --git a/src/testdir/test_cindent.vim b/src/testdir/test_cindent.vim
new file mode 100644 (file)
index 0000000..5685c2b
--- /dev/null
@@ -0,0 +1,16 @@
+" Test for cinoptions and cindent
+"
+" TODO: rewrite test3.in into this new style test
+
+func Test_cino_hash()
+  " Test that curbuf->b_ind_hash_comment is correctly reset
+  new
+  setlocal cindent cinoptions=#1
+  setlocal cinoptions=
+  call setline(1, ["#include <iostream>"])
+  call cursor(1, 1)
+  norm! o#include
+  "call feedkeys("o#include\<esc>", 't')
+  call assert_equal(["#include <iostream>", "#include"], getline(1,2))
+  bwipe!
+endfunc
index 3804bbe89347e7739ca77f737601a578161ef085..c956389cef344e2e0cd5336de8a828ab940433bd 100644 (file)
@@ -764,6 +764,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    423,
 /**/
     422,
 /**/