diff src/testdir/test_textformat.vim @ 20285:bce10d039e06 v8.2.0698

patch 8.2.0698: insert mode completion not fully tested Commit: https://github.com/vim/vim/commit/f9ab52e155dc13f59b654d754041fe78e17b9074 Author: Bram Moolenaar <Bram@vim.org> Date: Tue May 5 19:57:18 2020 +0200 patch 8.2.0698: insert mode completion not fully tested Problem: Insert mode completion not fully tested. Solution: Add a few more tests. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/6041)
author Bram Moolenaar <Bram@vim.org>
date Tue, 05 May 2020 20:00:05 +0200
parents aafedd368f40
children 505d97ea54da
line wrap: on
line diff
--- a/src/testdir/test_textformat.vim
+++ b/src/testdir/test_textformat.vim
@@ -975,6 +975,30 @@ func Test_whichwrap_multi_byte()
   bwipe!
 endfunc
 
+" Test for automatically adding comment leaders in insert mode
+func Test_threepiece_comment()
+  new
+  setlocal expandtab
+  call setline(1, ["\t/*"])
+  setlocal formatoptions=croql
+  call cursor(1, 3)
+  call feedkeys("A\<cr>\<cr>/", 'tnix')
+  call assert_equal(["\t/*", " *", " */"], getline(1, '$'))
+
+  " If a comment ends in a single line, then don't add it in the next line
+  %d
+  call setline(1, '/* line1 */')
+  call feedkeys("A\<CR>next line", 'xt')
+  call assert_equal(['/* line1 */', 'next line'], getline(1, '$'))
+
+  %d
+  " Copy the trailing indentation from the leader comment to a new line
+  setlocal autoindent noexpandtab
+  call feedkeys("a\t/*\tone\ntwo\n/", 'xt')
+  call assert_equal(["\t/*\tone", "\t *\ttwo", "\t */"], getline(1, '$'))
+  close!
+endfunc
+
 " Test for the 'f' flag in 'comments' (only the first line has the comment
 " string)
 func Test_firstline_comment()