patch 9.1.1259: some issues with comment package and tailing spaces
Problem: some issues with comment package and tailing spaces
Solution: correctly capture trailing spaces with the ac/ic text object
(Maxim Kim)
This commit fixes a few issues with the comment package:
1) both ac and ic incorrectly miss the last //
```
// hello trailing spaces
//
```
2) fix ac/ic with last empty comment line,
vac should also select last line with #
```py
# print("hello")
# print("world")
#
#
$endofbuffer$
```
closes: #17013
Signed-off-by: Maxim Kim <habamax@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/testdir/test_plugin_comment.vim b/src/testdir/test_plugin_comment.vim
index 1068c84..992a4f1 100644
--- a/src/testdir/test_plugin_comment.vim
+++ b/src/testdir/test_plugin_comment.vim
@@ -485,6 +485,72 @@
call assert_equal(["int main() {", "}"], result)
endfunc
+func Test_textobj_trailing_spaces_comment()
+ CheckScreendump
+ let lines = ['# print("hello") ', '# print("world") ', "#", 'print("!")']
+
+ let input_file = "test_textobj_trailing_spaces_input.py"
+ call writefile(lines, input_file, "D")
+
+ let buf = RunVimInTerminal('-c "packadd comment" ' .. input_file, {})
+
+ call term_sendkeys(buf, "jdac")
+ let output_file = "comment_textobj_trailing_spaces_comment.py"
+ call term_sendkeys(buf, $":w {output_file}\<CR>")
+ defer delete(output_file)
+
+ call StopVimInTerminal(buf)
+
+ let result = readfile(output_file)
+
+ call assert_equal(['print("!")'], result)
+endfunc
+
+func Test_textobj_trailing_spaces_last_comment()
+ CheckScreendump
+ let lines = ['# print("hello") ', '# print("world") ', "#", '', '']
+
+ let input_file = "test_textobj_trailing_spaces_last_input.py"
+ call writefile(lines, input_file, "D")
+
+ let buf = RunVimInTerminal('-c "packadd comment" ' .. input_file, {})
+
+ call term_sendkeys(buf, "jdac")
+ let output_file = "comment_textobj_trailing_spaces_last_comment.py"
+ call term_sendkeys(buf, $":w {output_file}\<CR>")
+ defer delete(output_file)
+
+ call StopVimInTerminal(buf)
+
+ let result = readfile(output_file)
+
+ call assert_equal([], result)
+endfunc
+
+func Test_textobj_last_line_empty_comment()
+ CheckScreendump
+ let lines =<< trim END
+ # print("hello")
+ #
+ #
+ END
+
+ let input_file = "test_textobj_last_line_empty_input.py"
+ call writefile(lines, input_file, "D")
+
+ let buf = RunVimInTerminal('-c "packadd comment" ' .. input_file, {})
+
+ call term_sendkeys(buf, "dac")
+ let output_file = "comment_textobj_last_line_empty_comment.py"
+ call term_sendkeys(buf, $":w {output_file}\<CR>")
+ defer delete(output_file)
+
+ call StopVimInTerminal(buf)
+
+ let result = readfile(output_file)
+
+ 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 2235744..e28782b 100644
--- a/src/version.c
+++ b/src/version.c
@@ -705,6 +705,8 @@
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1259,
+/**/
1258,
/**/
1257,