]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1293: comment plugin does not handle 'exclusive' selection for comment... v9.1.1293
authorMaxim Kim <habamax@gmail.com>
Sat, 12 Apr 2025 09:34:08 +0000 (11:34 +0200)
committerChristian Brabandt <cb@256bit.org>
Sat, 12 Apr 2025 09:34:08 +0000 (11:34 +0200)
Problem:  comment plugin does not handle 'exclusive' selection for
          comment object (@mawkish)
Solution: handle special case selection='exclusive' for inline comment
          object (Maxim Kim)

fixes: #17023
closes: #17098

Signed-off-by: Maxim Kim <habamax@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
runtime/pack/dist/opt/comment/autoload/comment.vim
src/testdir/test_plugin_comment.vim
src/version.c

index 183351d19dcfeecd2017ea8d1a49a9b4691ba0e9..a0ee7a72fb0f07dad16a21652bd9d5182afc458a 100644 (file)
@@ -158,6 +158,9 @@ export def ObjComment(inner: bool)
     else
         cursor(pos_end[1], pos_end[2])
         normal! v
+        if &selection == 'exclusive'
+            normal! lo
+        endif
         cursor(pos_start[1], pos_start[2])
     endif
 enddef
index 992a4f1b512e675a8487e4b82473f2e6a5bd1023..d4718bc520d703f0443d3671367dc2803b40a3d6 100644 (file)
@@ -677,3 +677,26 @@ func Test_inline_uncomment()
   let result = readfile(output_file)
   call assert_equal(['echo "Hello" This should be a comment'], result)
 endfunc
+
+func Test_textobj_selection_exclusive_inline_comment()
+  CheckScreendump
+  let lines =<< trim END
+    print("Hello") # selection exclusive
+  END
+
+  let input_file = "test_selection_exclusive_inline_comment_input.py"
+  call writefile(lines, input_file, "D")
+
+  let buf = RunVimInTerminal('-c "set selection=exclusive" -c "packadd comment" ' .. input_file, {})
+
+  call term_sendkeys(buf, "dac")
+
+  let output_file = "test_selection_exclusive_inline_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("Hello")'], result)
+endfunc
index 1b1cfd6b32b2e512d85692e84a801d06239b3c43..726629cdebc49637ad4a69a8910b29308ae5d20b 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1293,
 /**/
     1292,
 /**/