diff --git a/runtime/pack/dist/opt/comment/autoload/comment.vim b/runtime/pack/dist/opt/comment/autoload/comment.vim index a0ee7a72fb..ffe5a15161 100644 --- a/runtime/pack/dist/opt/comment/autoload/comment.vim +++ b/runtime/pack/dist/opt/comment/autoload/comment.vim @@ -1,7 +1,7 @@ vim9script # Maintainer: Maxim Kim -# Last Update: 2025-03-30 +# Last Update: 2025-04-22 # # Toggle comments # Usage: @@ -26,8 +26,8 @@ export def Toggle(...args: list): string if len(cms_l) == 1 && lnum1 == lnum2 && first_col < start_col var line_start = getline(lnum1)[0 : start_col - 1] var line_end = getline(lnum1)[start_col : -1] - line_end = line_end =~ $'^\s*{cms_l[0]}' ? - \ substitute(line_end, $'^\s*\zs{cms_l[0]}\s\ze\s*', line_end =~ '^\s' ? ' ' : '', '') : + line_end = line_end =~ $'\c^\s*{cms_l[0]}' ? + \ substitute(line_end, $'\c^\s*\zs{cms_l[0]}\s\ze\s*', line_end =~ '^\s' ? ' ' : '', '') : \ printf(substitute(cms, '%s\@!', '%%', ''), line_end) setline(lnum1, line_start .. line_end) return '' @@ -49,7 +49,7 @@ export def Toggle(...args: list): string endif indent_spaces = indent_spaces || (stridx(indent_str, ' ') != -1) indent_tabs = indent_tabs || (stridx(indent_str, "\t") != -1) - if getline(lnum) !~ $'^\s*{cms_l[0]}.*{cms_l[1]}$' + if getline(lnum) !~ $'\c^\s*{cms_l[0]}.*{cms_l[1]}$' comment = true endif endfor @@ -69,7 +69,7 @@ export def Toggle(...args: list): string strpart(getline(lnum), strlen(indent_current))) endif else - line = substitute(getline(lnum), $'^\s*\zs{cms_l[0]} \?\| \?{cms_l[1]}$', '', 'g') + line = substitute(getline(lnum), $'\c^\s*\zs{cms_l[0]} \?\| \?{cms_l[1]}$', '', 'g') endif add(lines, line) endfor diff --git a/src/testdir/test_plugin_comment.vim b/src/testdir/test_plugin_comment.vim index d4718bc520..800c2751b7 100644 --- a/src/testdir/test_plugin_comment.vim +++ b/src/testdir/test_plugin_comment.vim @@ -59,6 +59,29 @@ func Test_basic_uncomment() call assert_equal(["# vim9script", "", "def Hello()", ' echo "Hello"', "enddef"], result) endfunc +func Test_caseinsensitive_uncomment() + CheckScreendump + let lines =<< trim END + rem echo "Hello" + END + + let input_file = "test_caseinsensitive_uncomment_input.bat" + call writefile(lines, input_file, "D") + + let buf = RunVimInTerminal('-c "packadd comment" ' .. input_file, {}) + + call term_sendkeys(buf, "gcc") + let output_file = "comment_testinsensitive_uncomment_test.bat" + call term_sendkeys(buf, $":w {output_file}\") + defer delete(output_file) + + call StopVimInTerminal(buf) + + let result = readfile(output_file) + + call assert_equal(['echo "Hello"'], result) +endfunc + func Test_bothends_comment() CheckScreendump let lines =<< trim END @@ -551,6 +574,7 @@ func Test_textobj_last_line_empty_comment() call assert_equal([], result) endfunc + func Test_textobj_cursor_on_leading_space_comment() CheckScreendump let lines =<< trim END diff --git a/src/version.c b/src/version.c index 2d36034abd..6d3a295360 100644 --- a/src/version.c +++ b/src/version.c @@ -704,6 +704,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1336, /**/ 1335, /**/