mirror of
https://github.com/vim/vim.git
synced 2025-08-26 20:03:41 -04:00
patch 9.1.1336: comment plugin does not support case-insensitive 'commentstring'
Problem: comment plugin does not support case-insensitive 'commentstring' (char101) Solution: Use pattern '\c' to make the regex case-insensitive (Maxim Kim) fixes: #17184 closes: #17186 Signed-off-by: Maxim Kim <habamax@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
parent
362be6ba27
commit
dd776dd5f0
@ -1,7 +1,7 @@
|
|||||||
vim9script
|
vim9script
|
||||||
|
|
||||||
# Maintainer: Maxim Kim <habamax@gmail.com>
|
# Maintainer: Maxim Kim <habamax@gmail.com>
|
||||||
# Last Update: 2025-03-30
|
# Last Update: 2025-04-22
|
||||||
#
|
#
|
||||||
# Toggle comments
|
# Toggle comments
|
||||||
# Usage:
|
# Usage:
|
||||||
@ -26,8 +26,8 @@ export def Toggle(...args: list<string>): string
|
|||||||
if len(cms_l) == 1 && lnum1 == lnum2 && first_col < start_col
|
if len(cms_l) == 1 && lnum1 == lnum2 && first_col < start_col
|
||||||
var line_start = getline(lnum1)[0 : start_col - 1]
|
var line_start = getline(lnum1)[0 : start_col - 1]
|
||||||
var line_end = getline(lnum1)[start_col : -1]
|
var line_end = getline(lnum1)[start_col : -1]
|
||||||
line_end = line_end =~ $'^\s*{cms_l[0]}' ?
|
line_end = line_end =~ $'\c^\s*{cms_l[0]}' ?
|
||||||
\ substitute(line_end, $'^\s*\zs{cms_l[0]}\s\ze\s*', line_end =~ '^\s' ? ' ' : '', '') :
|
\ substitute(line_end, $'\c^\s*\zs{cms_l[0]}\s\ze\s*', line_end =~ '^\s' ? ' ' : '', '') :
|
||||||
\ printf(substitute(cms, '%s\@!', '%%', ''), line_end)
|
\ printf(substitute(cms, '%s\@!', '%%', ''), line_end)
|
||||||
setline(lnum1, line_start .. line_end)
|
setline(lnum1, line_start .. line_end)
|
||||||
return ''
|
return ''
|
||||||
@ -49,7 +49,7 @@ export def Toggle(...args: list<string>): string
|
|||||||
endif
|
endif
|
||||||
indent_spaces = indent_spaces || (stridx(indent_str, ' ') != -1)
|
indent_spaces = indent_spaces || (stridx(indent_str, ' ') != -1)
|
||||||
indent_tabs = indent_tabs || (stridx(indent_str, "\t") != -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
|
comment = true
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
@ -69,7 +69,7 @@ export def Toggle(...args: list<string>): string
|
|||||||
strpart(getline(lnum), strlen(indent_current)))
|
strpart(getline(lnum), strlen(indent_current)))
|
||||||
endif
|
endif
|
||||||
else
|
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
|
endif
|
||||||
add(lines, line)
|
add(lines, line)
|
||||||
endfor
|
endfor
|
||||||
|
@ -59,6 +59,29 @@ func Test_basic_uncomment()
|
|||||||
call assert_equal(["# vim9script", "", "def Hello()", ' echo "Hello"', "enddef"], result)
|
call assert_equal(["# vim9script", "", "def Hello()", ' echo "Hello"', "enddef"], result)
|
||||||
endfunc
|
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}\<CR>")
|
||||||
|
defer delete(output_file)
|
||||||
|
|
||||||
|
call StopVimInTerminal(buf)
|
||||||
|
|
||||||
|
let result = readfile(output_file)
|
||||||
|
|
||||||
|
call assert_equal(['echo "Hello"'], result)
|
||||||
|
endfunc
|
||||||
|
|
||||||
func Test_bothends_comment()
|
func Test_bothends_comment()
|
||||||
CheckScreendump
|
CheckScreendump
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
@ -551,6 +574,7 @@ func Test_textobj_last_line_empty_comment()
|
|||||||
|
|
||||||
call assert_equal([], result)
|
call assert_equal([], result)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_textobj_cursor_on_leading_space_comment()
|
func Test_textobj_cursor_on_leading_space_comment()
|
||||||
CheckScreendump
|
CheckScreendump
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
|
@ -704,6 +704,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1336,
|
||||||
/**/
|
/**/
|
||||||
1335,
|
1335,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user