diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-06-24 00:58:07 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-06-24 00:58:07 +0200 |
commit | e7eb92708ec2092a2fc11e78703b5dcf83844412 (patch) | |
tree | d00da20838b81404557c7b0ef17d2890f18175ac /src | |
parent | 0a1f56fcfe31be929e9cd8c3d81a984c960e4180 (diff) |
patch 8.1.1585: :let-heredoc does not trim enoughv8.1.1585
Problem: :let-heredoc does not trim enough.
Solution: Trim indent from the contents based on the indent of the first
line. Use let-heredoc in more tests.
Diffstat (limited to 'src')
-rw-r--r-- | src/eval.c | 51 | ||||
-rw-r--r-- | src/testdir/test_balloon.vim | 2 | ||||
-rw-r--r-- | src/testdir/test_cindent.vim | 114 | ||||
-rw-r--r-- | src/testdir/test_const.vim | 4 | ||||
-rw-r--r-- | src/testdir/test_debugger.vim | 56 | ||||
-rw-r--r-- | src/testdir/test_functions.vim | 15 | ||||
-rw-r--r-- | src/testdir/test_goto.vim | 288 | ||||
-rw-r--r-- | src/testdir/test_gui.vim | 18 | ||||
-rw-r--r-- | src/testdir/test_highlight.vim | 13 | ||||
-rw-r--r-- | src/testdir/test_join.vim | 166 | ||||
-rw-r--r-- | src/testdir/test_let.vim | 10 | ||||
-rw-r--r-- | src/testdir/test_memory_usage.vim | 34 | ||||
-rw-r--r-- | src/testdir/test_messages.vim | 24 | ||||
-rw-r--r-- | src/testdir/test_mksession_utf8.vim | 36 | ||||
-rw-r--r-- | src/testdir/test_normal.vim | 182 | ||||
-rw-r--r-- | src/testdir/test_popup.vim | 35 | ||||
-rw-r--r-- | src/testdir/test_popupwin.vim | 134 | ||||
-rw-r--r-- | src/testdir/test_profile.vim | 12 | ||||
-rw-r--r-- | src/testdir/test_quickfix.vim | 178 | ||||
-rw-r--r-- | src/testdir/test_xxd.vim | 16 | ||||
-rw-r--r-- | src/version.c | 2 |
21 files changed, 740 insertions, 650 deletions
diff --git a/src/eval.c b/src/eval.c index 3cfa4b7a55..ac9930b94f 100644 --- a/src/eval.c +++ b/src/eval.c @@ -1254,7 +1254,9 @@ heredoc_get(exarg_T *eap, char_u *cmd) char_u *marker; list_T *l; char_u *p; - int indent_len = 0; + int marker_indent_len = 0; + int text_indent_len = 0; + char_u *text_indent = NULL; if (eap->getline == NULL) { @@ -1268,15 +1270,17 @@ heredoc_get(exarg_T *eap, char_u *cmd) { cmd = skipwhite(cmd + 4); - // Trim the indentation from all the lines in the here document + // Trim the indentation from all the lines in the here document. // The amount of indentation trimmed is the same as the indentation of - // the :let command line. + // the first line after the :let command line. To find the end marker + // the indent of the :let command line is trimmed. p = *eap->cmdlinep; while (VIM_ISWHITE(*p)) { p++; - indent_len++; + marker_indent_len++; } + text_indent_len = -1; } // The marker is the next word. Default marker is "." @@ -1300,31 +1304,50 @@ heredoc_get(exarg_T *eap, char_u *cmd) for (;;) { - int i = 0; + int mi = 0; + int ti = 0; theline = eap->getline(NUL, eap->cookie, 0); - if (theline != NULL && indent_len > 0) - { - // trim the indent matching the first line - if (STRNCMP(theline, *eap->cmdlinep, indent_len) == 0) - i = indent_len; - } - if (theline == NULL) { semsg(_("E990: Missing end marker '%s'"), marker); break; } - if (STRCMP(marker, theline + i) == 0) + + // with "trim": skip the indent matching the :let line to find the + // marker + if (marker_indent_len > 0 + && STRNCMP(theline, *eap->cmdlinep, marker_indent_len) == 0) + mi = marker_indent_len; + if (STRCMP(marker, theline + mi) == 0) { vim_free(theline); break; } - if (list_append_string(l, theline + i, -1) == FAIL) + if (text_indent_len == -1 && *theline != NUL) + { + // set the text indent from the first line. + p = theline; + text_indent_len = 0; + while (VIM_ISWHITE(*p)) + { + p++; + text_indent_len++; + } + text_indent = vim_strnsave(theline, text_indent_len); + } + // with "trim": skip the indent matching the first line + if (text_indent != NULL) + for (ti = 0; ti < text_indent_len; ++ti) + if (theline[ti] != text_indent[ti]) + break; + + if (list_append_string(l, theline + ti, -1) == FAIL) break; vim_free(theline); } + vim_free(text_indent); return l; } diff --git a/src/testdir/test_balloon.vim b/src/testdir/test_balloon.vim index 793eb3a571..b3c680e111 100644 --- a/src/testdir/test_balloon.vim +++ b/src/testdir/test_balloon.vim @@ -13,7 +13,7 @@ if !CanRunVimInTerminal() throw 'Skipped: cannot make screendumps' endif -let s:common_script =<< [CODE] +let s:common_script =<< trim [CODE] call setline(1, ["one one one", "two tXo two", "three three three"]) set balloonevalterm balloonexpr=MyBalloonExpr() balloondelay=100 func MyBalloonExpr() diff --git a/src/testdir/test_cindent.vim b/src/testdir/test_cindent.vim index a813c6cbec..a8a2345577 100644 --- a/src/testdir/test_cindent.vim +++ b/src/testdir/test_cindent.vim @@ -18,23 +18,23 @@ func Test_cino_extern_c() " Test for cino-E let without_ind =<< trim [CODE] - #ifdef __cplusplus - extern "C" { - #endif - int func_a(void); - #ifdef __cplusplus - } - #endif + #ifdef __cplusplus + extern "C" { + #endif + int func_a(void); + #ifdef __cplusplus + } + #endif [CODE] let with_ind =<< trim [CODE] - #ifdef __cplusplus - extern "C" { - #endif - int func_a(void); - #ifdef __cplusplus - } - #endif + #ifdef __cplusplus + extern "C" { + #endif + int func_a(void); + #ifdef __cplusplus + } + #endif [CODE] new setlocal cindent cinoptions=E0 @@ -89,30 +89,30 @@ func Test_cindent_expr() endfunc setl expandtab sw=8 indentkeys+=; indentexpr=MyIndentFunction() let testinput =<< trim [CODE] - var_a = something() - b = something() + var_a = something() + b = something() [CODE] call setline(1, testinput) call cursor(1, 1) call feedkeys("^\<c-v>j$A;\<esc>", 'tnix') - let expected =<< trim [CODE] - var_a = something(); - b = something(); - [CODE] + let expected =<< [CODE] + var_a = something(); +b = something(); +[CODE] call assert_equal(expected, getline(1, '$')) %d - let testinput =<< trim [CODE] - var_a = something() - b = something() - [CODE] + let testinput =<< [CODE] + var_a = something() + b = something() +[CODE] call setline(1, testinput) call cursor(1, 1) call feedkeys("^\<c-v>j$A;\<esc>", 'tnix') - let expected =<< trim [CODE] - var_a = something(); - b = something() - [CODE] + let expected =<< [CODE] + var_a = something(); + b = something() +[CODE] call assert_equal(expected, getline(1, '$')) bw! endfunc @@ -2069,14 +2069,14 @@ func Test_cindent_2() let &wm = &columns - 20 let code =<< trim [CODE] - { - - /* this is - * a real serious important big - * comment - */ - /* insert " about life, the universe, and the rest" after "serious" */ - } + { + + /* this is + * a real serious important big + * comment + */ + /* insert " about life, the universe, and the rest" after "serious" */ + } [CODE] call append(0, code) @@ -3243,32 +3243,32 @@ func Test_cindent_30() setl cindent ts=4 sw=4 setl cino=+20 - let code =<< trim [CODE] - void - foo() - { - if (a) - { - } else - asdf; - } - [CODE] + let code =<< [CODE] + void +foo() +{ + if (a) + { + } else + asdf; +} +[CODE] call append(0, code) normal gg normal ]]=][ - let expected =<< trim [CODE] - void - foo() - { - if (a) - { - } else - asdf; - } + let expected =<< [CODE] + void +foo() +{ + if (a) + { + } else + asdf; +} - [CODE] +[CODE] call assert_equal(expected, getline(1, '$')) enew! | close @@ -3461,7 +3461,7 @@ func Test_cindent_34() normal =][ let expected =<< trim [CODE] - + void func(int a #if defined(FOO) diff --git a/src/testdir/test_const.vim b/src/testdir/test_const.vim index d4dccb1b83..d93de72bd4 100644 --- a/src/testdir/test_const.vim +++ b/src/testdir/test_const.vim @@ -18,7 +18,7 @@ func Test_define_var_with_lock() const n = v:null const bl = 0zC0FFEE const here =<< trim EOS - hello + hello EOS call assert_true(exists('i')) @@ -84,7 +84,7 @@ func Test_define_l_var_with_lock() const l:n = v:null const l:bl = 0zC0FFEE const l:here =<< trim EOS - hello + hello EOS call assert_fails('let l:i = 1', 'E741:') diff --git a/src/testdir/test_debugger.vim b/src/testdir/test_debugger.vim index 4528b2bdbc..811717208e 100644 --- a/src/testdir/test_debugger.vim +++ b/src/testdir/test_debugger.vim @@ -26,27 +26,29 @@ func Test_Debugger() endif " Create a Vim script with some functions - call writefile([ - \ 'func Foo()', - \ ' let var1 = 1', - \ ' let var2 = Bar(var1) + 9', - \ ' return var2', - \ 'endfunc', - \ 'func Bar(var)', - \ ' let var1 = 2 + a:var', - \ ' let var2 = Bazz(var1) + 4', - \ ' return var2', - \ 'endfunc', - \ 'func Bazz(var)', - \ ' try', - \ ' let var1 = 3 + a:var', - \ ' let var3 = "another var"', - \ ' let var3 = "value2"', - \ ' catch', - \ ' let var4 = "exception"', - \ ' endtry', - \ ' return var1', - \ 'endfunc'], 'Xtest.vim') + let lines =<< trim END + func Foo() + let var1 = 1 + let var2 = Bar(var1) + 9 + return var2 + endfunc + func Bar(var) + let var1 = 2 + a:var + let var2 = Bazz(var1) + 4 + return var2 + endfunc + func Bazz(var) + try + let var1 = 3 + a:var + let var3 = "another var" + let var3 = "value2" + catch + let var4 = "exception" + endtry + return var1 + endfunc + END + call writefile(lines, 'Xtest.vim') " Start Vim in a terminal let buf = RunVimInTerminal('-S Xtest.vim', {}) @@ -294,11 +296,13 @@ func Test_Debugger() " Tests for :breakadd file and :breakadd here " Breakpoints should be set before sourcing the file - call writefile([ - \ 'let var1 = 10', - \ 'let var2 = 20', - \ 'let var3 = 30', - \ 'let var4 = 40'], 'Xtest.vim') + let lines =<< trim END + let var1 = 10 + let var2 = 20 + let var3 = 30 + let var4 = 40 + END + call writefile(lines, 'Xtest.vim') " Start Vim in a terminal let buf = RunVimInTerminal('Xtest.vim', {}) diff --git a/src/testdir/test_functions.vim b/src/testdir/test_functions.vim index d574a8baed..cd3f253bbe 100644 --- a/src/testdir/test_functions.vim +++ b/src/testdir/test_functions.vim @@ -277,13 +277,14 @@ func Test_resolve_win32() if executable('cscript') new Xfile wq - call writefile([ - \ 'Set fs = CreateObject("Scripting.FileSystemObject")', - \ 'Set ws = WScript.CreateObject("WScript.Shell")', - \ 'Set shortcut = ws.CreateShortcut("Xlink.lnk")', - \ 'shortcut.TargetPath = fs.BuildPath(ws.CurrentDirectory, "Xfile")', - \ 'shortcut.Save' - \], 'link.vbs') + let lines =<< trim END + Set fs = CreateObject("Scripting.FileSystemObject") + Set ws = WScript.CreateObject("WScript.Shell") + Set shortcut = ws.CreateShortcut("Xlink.lnk") + shortcut.TargetPath = fs.BuildPath(ws.CurrentDirectory, "Xfile") + shortcut.Save + END + call writefile(lines, 'link.vbs') silent !cscript link.vbs call delete('link.vbs') call assert_equal(s:normalize_fname(getcwd() . '\Xfile'), s:normalize_fname(resolve('./Xlink.lnk'))) diff --git a/src/testdir/test_goto.vim b/src/testdir/test_goto.vim index c00e4e4376..1248de3f01 100644 --- a/src/testdir/test_goto.vim +++ b/src/testdir/test_goto.vim @@ -16,12 +16,12 @@ endfunc func Test_gD() let lines =<< trim [CODE] - int x; - - int func(void) - { - return x; - } + int x; + + int func(void) + { + return x; + } [CODE] call XTest_goto_decl('gD', lines, 1, 5) @@ -29,12 +29,12 @@ endfunc func Test_gD_too() let lines =<< trim [CODE] - Filename x; - - int Filename - int func() { Filename x; - return x; + + int Filename + int func() { + Filename x; + return x; [CODE] call XTest_goto_decl('gD', lines, 1, 10) @@ -42,13 +42,13 @@ endfunc func Test_gD_comment() let lines =<< trim [CODE] - /* int x; */ - int x; - - int func(void) - { - return x; - } + /* int x; */ + int x; + + int func(void) + { + return x; + } [CODE] call XTest_goto_decl('gD', lines, 2, 5) @@ -56,13 +56,13 @@ endfunc func Test_gD_inline_comment() let lines =<< trim [CODE] - int y /* , x */; - int x; - - int func(void) - { - return x; - } + int y /* , x */; + int x; + + int func(void) + { + return x; + } [CODE] call XTest_goto_decl('gD', lines, 2, 5) @@ -70,13 +70,13 @@ endfunc func Test_gD_string() let lines =<< trim [CODE] - char *s[] = "x"; - int x = 1; - - int func(void) - { - return x; - } + char *s[] = "x"; + int x = 1; + + int func(void) + { + return x; + } [CODE] call XTest_goto_decl('gD', lines, 2, 5) @@ -84,12 +84,12 @@ endfunc func Test_gD_string_same_line() let lines =<< trim [CODE] - char *s[] = "x", int x = 1; - - int func(void) - { - return x; - } + char *s[] = "x", int x = 1; + + int func(void) + { + return x; + } [CODE] call XTest_goto_decl('gD', lines, 1, 22) @@ -97,13 +97,13 @@ endfunc func Test_gD_char() let lines =<< trim [CODE] - char c = 'x'; - int x = 1; - - int func(void) - { - return x; - } + char c = 'x'; + int x = 1; + + int func(void) + { + return x; + } [CODE] call XTest_goto_decl('gD', lines, 2, 5) @@ -111,12 +111,12 @@ endfunc func Test_gd() let lines =<< trim [CODE] - int x; - - int func(int x) - { - return x; - } + int x; + + int func(int x) + { + return x; + } [CODE] call XTest_goto_decl('gd', lines, 3, 14) @@ -124,15 +124,15 @@ endfunc func Test_gd_not_local() let lines =<< trim [CODE] - int func1(void) - { - return x; - } - - int func2(int x) - { - return x; - } + int func1(void) + { + return x; + } + + int func2(int x) + { + return x; + } [CODE] call XTest_goto_decl('gd', lines, 3, 10) @@ -140,11 +140,11 @@ endfunc func Test_gd_kr_style() let lines =<< trim [CODE] - int func(x) - int x; - { - return x; - } + int func(x) + int x; + { + return x; + } [CODE] call XTest_goto_decl('gd', lines, 2, 7) @@ -152,15 +152,15 @@ endfunc func Test_gd_missing_braces() let lines =<< trim [CODE] - def func1(a) - a + 1 - end - - a = 1 - - def func2() - return a - end + def func1(a) + a + 1 + end + + a = 1 + + def func2() + return a + end [CODE] call XTest_goto_decl('gd', lines, 1, 11) @@ -168,12 +168,12 @@ endfunc func Test_gd_comment() let lines =<< trim [CODE] - int func(void) - { - /* int x; */ - int x; - return x; - } + int func(void) + { + /* int x; */ + int x; + return x; + } [CODE] call XTest_goto_decl('gd', lines, 4, 7) @@ -181,12 +181,12 @@ endfunc func Test_gd_comment_in_string() let lines =<< trim [CODE] - int func(void) - { - char *s ="//"; int x; - int x; - return x; - } + int func(void) + { + char *s ="//"; int x; + int x; + return x; + } [CODE] call XTest_goto_decl('gd', lines, 3, 22) @@ -195,12 +195,12 @@ endfunc func Test_gd_string_in_comment() set comments= let lines =<< trim [CODE] - int func(void) - { - /* " */ int x; - int x; - return x; - } + int func(void) + { + /* " */ int x; + int x; + return x; + } [CODE] call XTest_goto_decl('gd', lines, 3, 15) @@ -209,10 +209,10 @@ endfunc func Test_gd_inline_comment() let lines =<< trim [CODE] - int func(/* x is an int */ int x) - { - return x; - } + int func(/* x is an int */ int x) + { + return x; + } [CODE] call XTest_goto_decl('gd', lines, 1, 32) @@ -220,10 +220,10 @@ endfunc func Test_gd_inline_comment_only() let lines =<< trim [CODE] - int func(void) /* one lonely x */ - { - return x; - } + int func(void) /* one lonely x */ + { + return x; + } [CODE] call XTest_goto_decl('gd', lines, 3, 10) @@ -231,16 +231,16 @@ endfunc func Test_gd_inline_comment_body() let lines =<< trim [CODE] - int func(void) - { - int y /* , x */; - - for (/* int x = 0 */; y < 2; y++); - - int x = 0; - - return x; - } + int func(void) + { + int y /* , x */; + + for (/* int x = 0 */; y < 2; y++); + + int x = 0; + + return x; + } [CODE] call XTest_goto_decl('gd', lines, 7, 7) @@ -248,10 +248,10 @@ endfunc func Test_gd_trailing_multiline_comment() let lines =<< trim [CODE] - int func(int x) /* x is an int */ - { - return x; - } + int func(int x) /* x is an int */ + { + return x; + } [CODE] call XTest_goto_decl('gd', lines, 1, 14) @@ -259,10 +259,10 @@ endfunc func Test_gd_trailing_comment() let lines =<< trim [CODE] - int func(int x) // x is an int - { - return x; - } + int func(int x) // x is an int + { + return x; + } [CODE] call XTest_goto_decl('gd', lines, 1, 14) @@ -270,25 +270,25 @@ endfunc func Test_gd_string() let lines =<< trim [CODE] - int func(void) - { - char *s = "x"; - int x = 1; - - return x; - } + int func(void) + { + char *s = "x"; + int x = 1; + + return x; + } [CODE] call XTest_goto_decl('gd', lines, 4, 7) endfunc func Test_gd_string_only() let lines =<< trim [CODE] - int func(void) - { - char *s = "x"; - - return x; - } + int func(void) + { + char *s = "x"; + + return x; + } [CODE] call XTest_goto_decl('gd', lines, 5, 10) @@ -311,21 +311,21 @@ endfunc func Test_gd_local_block() let lines =<< trim [CODE] int main() - { - char *a = "NOT NULL"; - if(a) - { - char *b = a; - printf("%s\n", b); - } - else { - char *b = "NULL"; - return b; + char *a = "NOT NULL"; + if(a) + { + char *b = a; + printf("%s\n", b); + } + else + { + char *b = "NULL"; + return b; + } + + return 0; } - - return 0; - } [CODE] call XTest_goto_decl('1gd', lines, 11, 11) diff --git a/src/testdir/test_gui.vim b/src/testdir/test_gui.vim index 7f94e6a8d9..97fd12b2b2 100644 --- a/src/testdir/test_gui.vim +++ b/src/testdir/test_gui.vim @@ -792,10 +792,11 @@ endfunc func Test_gui_dash_g() let cmd = GetVimCommand('Xscriptgui') call writefile([""], "Xtestgui") - call writefile([ - \ 'au GUIEnter * call writefile(["insertmode: " . &insertmode], "Xtestgui")', - \ 'au GUIEnter * qall', - \ ], 'Xscriptgui') + let lines =<< trim END + au GUIEnter * call writefile(["insertmode: " . &insertmode], "Xtestgui") + au GUIEnter * qall + END + call writefile(lines, 'Xscriptgui') call system(cmd . ' -g') call WaitForAssert({-> assert_equal(['insertmode: 0'], readfile('Xtestgui'))}) @@ -807,10 +808,11 @@ endfunc func Test_gui_dash_y() let cmd = GetVimCommand('Xscriptgui') call writefile([""], "Xtestgui") - call writefile([ - \ 'au GUIEnter * call writefile(["insertmode: " . &insertmode], "Xtestgui")', - \ 'au GUIEnter * qall', - \ ], 'Xscriptgui') + let lines =<< trim END + au GUIEnter * call writefile(["insertmode: " . &insertmode], "Xtestgui") + au GUIEnter * qall + END + call writefile(lines, 'Xscriptgui') call system(cmd . ' -y') call WaitForAssert({-> assert_equal(['insertmode: 1'], readfile('Xtestgui'))}) diff --git a/src/testdir/test_highlight.vim b/src/testdir/test_highlight.vim index 78dbead8b9..09f80670f1 100644 --- a/src/testdir/test_highlight.vim +++ b/src/testdir/test_highlight.vim @@ -578,12 +578,13 @@ func Test_wincolor() throw 'Skipped: cannot make screendumps' endif - call writefile([ - \ 'set cursorline cursorcolumn rnu', - \ 'call setline(1, ["","1111111111","22222222222","3 here 3",""])', - \ 'set wincolor=Pmenu', - \ '/here', - \ ], 'Xtest_wincolor') + let lines =<< trim END + set cursorline cursorcolumn rnu + call setline(1, ["","1111111111","22222222222","3 here 3",""]) + set wincolor=Pmenu + /here + END + call writefile(lines, 'Xtest_wincolor') let buf = RunVimInTerminal('-S Xtest_wincolor', {'rows': 8}) call term_wait(buf) call term_sendkeys(buf, "2G5lvj") diff --git a/src/testdir/test_join.vim b/src/testdir/test_join.vim index 1b4da6f41a..78835b2ccf 100644 --- a/src/testdir/test_join.vim +++ b/src/testdir/test_join.vim @@ -100,22 +100,22 @@ ert " Expected output let expected =<< trim [DATA] - asdfasdf. asdf - asdfasdf. asdf - asdfasdf. asdf - asdfasdf. asdf - asdfasdf. asdf - asdfasdf. asdf - asdfasdf. asdf - asdfasdf asdf - asdfasdf asdf - asdfasdf asdf - asdfasdf asdf - asdfasdf asdf - asdfasdf asdf - asdfasdf asdf - zx cvn. as dfg? hjkl iop! ert ernop - zx cvn. as dfg? hjkl iop! ert ernop + asdfasdf. asdf + asdfasdf. asdf + asdfasdf. asdf + asdfasdf. asdf + asdfasdf. asdf + asdfasdf. asdf + asdfasdf. asdf + asdfasdf asdf + asdfasdf asdf + asdfasdf asdf + asdfasdf asdf + asdfasdf asdf + asdfasdf asdf + asdfasdf asdf + zx cvn. as dfg? hjkl iop! ert ernop + zx cvn. as dfg? hjkl iop! ert ernop [DATA] call assert_equal(expected, getline(1, '$')) @@ -142,22 +142,22 @@ ert " Expected output let expected =<< trim [DATA] - asdfasdf. asdf - asdfasdf. asdf - asdfasdf. asdf - asdfasdf. asdf - asdfasdf. asdf - asdfasdf. asdf - asdfasdf. asdf - asdfasdf asdf - asdfasdf asdf - asdfasdf asdf - asdfasdf asdf - asdfasdf asdf - asdfasdf asdf - asdfasdf asdf - zx cvn. as dfg? hjkl iop! ert enop - zx cvn. as dfg? hjkl iop! ert ernop + asdfasdf. asdf + asdfasdf. asdf + asdfasdf. asdf + asdfasdf. asdf + asdfasdf. asdf + asdfasdf. asdf + asdfasdf. asdf + asdfasdf asdf + asdfasdf asdf + asdfasdf asdf + asdfasdf asdf + asdfasdf asdf + asdfasdf asdf + asdfasdf asdf + zx cvn. as dfg? hjkl iop! ert enop + zx cvn. as dfg? hjkl iop! ert ernop [DATA] @@ -176,21 +176,21 @@ ert " Expected output let expected =<< trim [DATA] - asdfasdf. asdf - asdfasdf. asdf - asdfasdf. asdf - asdfasdf. asdf - asdfasdf. asdf - asdfasdf. asdf - asdfasdf. asdf - asdfasdf asdf - asdfasdf asdf - asdfasdf asdf - asdfasdf asdf - asdfasdf asdf - asdfasdf asdf - asdfasdf asdf - zx cvn. as dfg? hjkl iop! ert a + asdfasdf. asdf + asdfasdf. asdf + asdfasdf. asdf + asdfasdf. asdf + asdfasdf. asdf + asdfasdf. asdf + asdfasdf. asdf + asdfasdf asdf + asdfasdf asdf + asdfasdf asdf + asdfasdf asdf + asdfasdf asdf + asdfasdf asdf + asdfasdf asdf + zx cvn. as dfg? hjkl iop! ert a [DATA] call assert_equal(expected, getline(1, '$')) @@ -255,18 +255,18 @@ action(); " Expected output let expected =<< trim [CODE] -{ -/* Make sure the previous comment leader is not removed. */ -/* Make sure the previous comment leader is not removed. */ -// Should the next comment leader be left alone? Yes. -// Should the next comment leader be left alone? Yes. -/* Here the comment leader should be left intact. */ // And so should this one. -/* Here the comment leader should be left intact. */ // And so should this one. -if (condition) // Remove the next comment leader! OK, I will. -action(); -if (condition) // Remove the next comment leader! OK, I will. -action(); -} + { + /* Make sure the previous comment leader is not removed. */ + /* Make sure the previous comment leader is not removed. */ + // Should the next comment leader be left alone? Yes. + // Should the next comment leader be left alone? Yes. + /* Here the comment leader should be left intact. */ // And so should this one. + /* Here the comment leader should be left intact. */ // And so should this one. + if (condition) // Remove the next comment leader! OK, I will. + action(); + if (condition) // Remove the next comment leader! OK, I will. + action(); + } [CODE] call assert_equal(expected, getline(1, '$')) @@ -378,30 +378,30 @@ int i = 7 /* foo *// 3 exe "normal oSome code!\<CR>// Make sure backspacing does not remove this comment leader.\<Esc>0i\<C-H>\<Esc>" " Expected output - let expected =<< [CODE] -{ -/* Make sure the previous comment leader is not removed. */ -/* Make sure the previous comment leader is not removed. */ -/* List: item1 foo bar baz foo bar baz item2 foo bar baz foo bar baz */ -/* List: item1 foo bar baz foo bar baz item2 foo bar baz foo bar baz */ -// Should the next comment leader be left alone? Yes. -// Should the next comment leader be left alone? Yes. -/* Here the comment leader should be left intact. */ // And so should this one. -/* Here the comment leader should be left intact. */ // And so should this one. -if (condition) // Remove the next comment leader! OK, I will. - action(); -if (condition) // Remove the next comment leader! OK, I will. - action(); -int i = 7 /* foo *// 3 // comment - ; -int i = 7 /* foo *// 3 // comment - ; -># Note that the last character of the ending comment leader (left angle bracket) is a comment leader itself. Make sure that this comment leader is not removed from the next line #< < On this line a new comment is opened which spans 2 lines. This comment should retain its comment leader. -># Note that the last character of the ending comment leader (left angle bracket) is a comment leader itself. Make sure that this comment leader is not removed from the next line #< < On this line a new comment is opened which spans 2 lines. T |