patch 9.1.1240: Regression with ic/ac text objects and comment plugin
Problem: Regression with ic/ac text objects and comment plugin
Solution: Fix regression, update tests (Maxim Kim)
fix regression: sometimes ic/ac should be line-wise
```
int main() {
// multilple comments
// cursor is between them
}
# dac ->
int main() {
}
```
closes: #16947
closes: #16980
Signed-off-by: Maxim Kim <habamax@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
f9f4e27ad7
commit
08283b28af
@ -151,7 +151,7 @@ export def ObjComment(inner: bool)
|
||||
endif
|
||||
endif
|
||||
|
||||
if (pos_end[2] == (getline(pos_end[1])->len() ?? 1)) && pos_start[2] == 1
|
||||
if (pos_end[2] == (getline(pos_end[1])->len() ?? 1)) && pos_start[2] <= 1
|
||||
cursor(pos_end[1], 1)
|
||||
normal! V
|
||||
cursor(pos_start[1], 1)
|
||||
|
||||
@ -457,7 +457,7 @@ func Test_textobj_cursor_on_leading_space_comment()
|
||||
|
||||
let result = readfile(output_file)
|
||||
|
||||
call assert_equal(["int main() {", "", "}"], result)
|
||||
call assert_equal(["int main() {", "}"], result)
|
||||
endfunc
|
||||
|
||||
func Test_textobj_conseq_comment()
|
||||
@ -514,3 +514,49 @@ func Test_textobj_conseq_comment2()
|
||||
|
||||
call assert_equal(["int main() {", " printf(\"hello\");", "", " // world", " printf(\"world\");", "}"], result)
|
||||
endfunc
|
||||
|
||||
func Test_inline_comment()
|
||||
CheckScreendump
|
||||
let lines =<< trim END
|
||||
echo "Hello" This should be a comment
|
||||
END
|
||||
|
||||
let input_file = "test_inline_comment_input.vim"
|
||||
call writefile(lines, input_file, "D")
|
||||
|
||||
let buf = RunVimInTerminal('-c "packadd comment" -c "nnoremap <expr> gC comment#Toggle()..''$''" ' .. input_file, {})
|
||||
|
||||
call term_sendkeys(buf, "fTgC")
|
||||
|
||||
let output_file = "comment_inline_test.vim"
|
||||
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" " This should be a comment'], result)
|
||||
endfunc
|
||||
|
||||
func Test_inline_uncomment()
|
||||
CheckScreendump
|
||||
let lines =<< trim END
|
||||
echo "Hello" " This should be a comment
|
||||
END
|
||||
|
||||
let input_file = "test_inline_uncomment_input.vim"
|
||||
call writefile(lines, input_file, "D")
|
||||
|
||||
let buf = RunVimInTerminal('-c "packadd comment" -c "nnoremap <expr> gC comment#Toggle()..''$''" ' .. input_file, {})
|
||||
|
||||
call term_sendkeys(buf, '$F"gC')
|
||||
|
||||
let output_file = "uncomment_inline_test.vim"
|
||||
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" This should be a comment'], result)
|
||||
endfunc
|
||||
|
||||
@ -704,6 +704,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
1240,
|
||||
/**/
|
||||
1239,
|
||||
/**/
|
||||
|
||||
Reference in New Issue
Block a user