patch 9.1.1240: Regression with ic/ac text objects and comment plugin
Commit:
https://github.com/vim/vim/commit/08283b28afae1a75ddec1fad1b6dd1cb267aab12
Author: Maxim Kim <
hab...@gmail.com>
Date: Wed Mar 26 19:04:20 2025 +0100
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 <
hab...@gmail.com>
Signed-off-by: Christian Brabandt <
c...@256bit.org>
diff --git a/runtime/pack/dist/opt/comment/autoload/comment.vim b/runtime/pack/dist/opt/comment/autoload/comment.vim
index 34f0d680a..570080604 100644
--- a/runtime/pack/dist/opt/comment/autoload/comment.vim
+++ b/runtime/pack/dist/opt/comment/autoload/comment.vim
@@ -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)
diff --git a/src/testdir/test_plugin_comment.vim b/src/testdir/test_plugin_comment.vim
index a0425d58d..b1d356be9 100644
--- a/src/testdir/test_plugin_comment.vim
+++ b/src/testdir/test_plugin_comment.vim
@@ -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
diff --git a/src/version.c b/src/version.c
index dcb428e45..9ada5e0f9 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 */
+/**/
+ 1240,
/**/
1239,
/**/