runtime(comment): commenting might be off by one column

Commit: 
https://github.com/vim/vim/commit/e021f39b79339385d6f70001cb35a79c611456ff
Author: Konfekt <konf...@users.noreply.github.com>
Date:   Tue Oct 1 20:02:15 2024 +0200

    runtime(comment): commenting might be off by one column
    
    getpos columns start at 1 and not 0 as do arrays
    
    closes: #15774
    
    Signed-off-by: Konfekt <konf...@users.noreply.github.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 6617136e6..c758a7d40 100644
--- a/runtime/pack/dist/opt/comment/autoload/comment.vim
+++ b/runtime/pack/dist/opt/comment/autoload/comment.vim
@@ -22,13 +22,13 @@ export def Toggle(...args: list<string>): string
     var cms_l = split(escape(cms, '*.'), '\s*%s\s*')
 
     var first_col = indent(lnum1)
-    var start_col = getpos("'[")[2]
+    var start_col = getpos("'[")[2] - 1
     if len(cms_l) == 1 && lnum1 == lnum2 && first_col < start_col
-        var line_start = getline(lnum1)[0 : max([0, start_col - 2])]
-        var line_end = getline(lnum1)[start_col - 1 : -1]
-        line_end = line_end =~# $'^\s*{cms_l[0]}' ?
-                    \ substitute(line_end, $'^\s*\zs{cms_l[0]}', '', '') :
-                    \ printf(substitute(cms, '%s\@!', '%%', 'g'), line_end)
+        var line_start = getline(lnum1)[0 : start_col - 1]
+        var line_end = getline(lnum1)[start_col : -1]
+        line_end = line_end =~ $'^\s*{cms_l[0]}' ?
+                    \ substitute(line_end, $'^\s*\zs{cms_l[0]}\s\ze\s*', 
line_end =~ '^\s' ? ' ' : '', '') :
+                    \ printf(substitute(cms, '%s\@!', '%%', ''), line_end)
         setline(lnum1, line_start .. line_end)
         return ''
     endif
diff --git a/runtime/pack/dist/opt/comment/doc/comment.txt 
b/runtime/pack/dist/opt/comment/doc/comment.txt
index af1251a07..2bd874101 100644
--- a/runtime/pack/dist/opt/comment/doc/comment.txt
+++ b/runtime/pack/dist/opt/comment/doc/comment.txt
@@ -1,4 +1,4 @@
-*comment.txt*   For Vim version 9.1.  Last change:  2024 Sep 30
+*comment.txt*   For Vim version 9.1.  Last change:  2024 Oct 01
 
 
                  VIM REFERENCE MANUAL
@@ -38,6 +38,11 @@ depends on the first line of the range of lines to act upon. 
 When it matches
 a comment marker, the line will be un-commented, if it doesn't, the line will
 be commented out.  Blank and empty lines are ignored.
 
+The value of 'commentstring' is the same for the entire buffer and determined
+by its filetype (|filetypes|). To adapt it within the buffer for embedded
+languages, you can use a plug-in such as
+https://github.com/suy/vim-context-commentstring.
+
 The comment marker will always be padded with blanks whether or not the
 'commentstring' value contains whitespace around "%s".
 

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/E1svhOp-004oQc-Ad%40256bit.org.

Raspunde prin e-mail lui