Commit: patch 9.2.0737: tests: comment test can be improved

3 views
Skip to first unread message

Christian Brabandt

unread,
4:45 AM (4 hours ago) 4:45 AM
to vim...@googlegroups.com
patch 9.2.0737: tests: comment test can be improved

Commit: https://github.com/vim/vim/commit/12286e442665c69587d923efde22b6e3f4c556c9
Author: Maxim Kim <hab...@gmail.com>
Date: Sat Jun 27 08:35:08 2026 +0000

patch 9.2.0737: tests: comment test can be improved

Problem: tests: comment test can be improved
Solution: Simplify tests (Maxim Kim)

Currently test suite for the comment package uses separate vim in
terminal to do tests, which is inefficient and unnecessary complex.

The reason is the comment.Toggle() uses '<stack>' to get function name
for the opfunc and this fools vim's test runner.

- use lambda func for opfunc inside Toggle()
- simplify tests not to use terminal

closes: #20649

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 74e091c35..13fa59c83 100644
--- a/runtime/pack/dist/opt/comment/autoload/comment.vim
+++ b/runtime/pack/dist/opt/comment/autoload/comment.vim
@@ -1,7 +1,7 @@
vim9script

# Maintainer: Maxim Kim <hab...@gmail.com>
-# Last Update: 2025-06-13
+# Last Update: 2026-06-27
#
# Toggle comments
# Usage:
@@ -11,70 +11,68 @@ vim9script
# xnoremap <silent> <expr> gc comment.Toggle()
# nnoremap <silent> <expr> gcc comment.Toggle() .. '_'
# nnoremap <silent> <expr> gC comment.Toggle() .. '$'
-export def Toggle(...args: list<string>): string
- if len(args) == 0
- &opfunc = matchstr(expand('<stack>'), '[^. ]*\ze[')
- return 'g@'
- endif
- if empty(&cms) || !&ma | return '' | endif
- var cms = substitute(substitute(&cms, '\S\zs%s\s*', ' %s', ''), '%s\ze\S', '%s ', '')
- var [lnum1, lnum2] = [line("'["), line("']")]
- var cms_l = split(escape(cms, '*.\^$['), '\s*%s\s*')
+export def Toggle(): string
+ &opfunc = (_) => {
+ if empty(&cms) || !&ma | return | endif
+ var cms = substitute(substitute(&cms, '\S\zs%s\s*', ' %s', ''), '%s\ze\S', '%s ', '')
+ var [lnum1, lnum2] = [line("'["), line("']")]
+ var cms_l = split(escape(cms, '*.\^$['), '\s*%s\s*')

- var first_col = indent(lnum1)
- var start_col = getpos("'[")[2] - 1
- if len(cms_l) == 1 && lnum1 == lnum2 && first_col < start_col
+ var first_col = indent(lnum1)
+ var start_col = getpos("'[")[2] - 1
+ if len(cms_l) == 1 && lnum1 == lnum2 && first_col < start_col
var line_start = getline(lnum1)[0 : start_col - 1]
var line_end = getline(lnum1)[start_col : -1]
line_end = line_end =~ $'
Reply all
Reply to author
Forward
0 new messages