[vim/vim] Screen lines corrupted with matchparen plugin and cpo-$ (Issue #18647)

3 views
Skip to first unread message

julio-b

unread,
Oct 26, 2025, 11:49:17 PM (4 days ago) Oct 26
to vim/vim, Subscribed
julio-b created an issue (vim/vim#18647)

Steps to reproduce

  1. Execute this command in bash:
vim --clean +'set cpo+=$' +'run plugin/matchparen.vim' +'bo vnew | winc p | vert res 40' <( cat <<EOF
a long line with parentheses ( ) that wraps here
line 1    line 1 
line 2    line 2 
line 3    line 3 
line 4    line 4 
line 5    line 5 
line 6    line 6 
line 7    line 7 
line 8    line 8 
line 9    line 9 
line 10   line 10
line 11   line 11
line 12   line 12
line 13   line 13
line 14   line 14
EOF
)
  1. Type: ct(
  2. Type anything, eg.: qwe123asdqwe. Each keystroke deletes the next line.

A :redraw! command or <C-L> is required to restore the screen contents.

https://github.com/user-attachments/assets/bb8bcc67-4963-4eca-ae20-7a2c028ac763

Expected behaviour

If we use cf( instead of ct( then it works as expected.

Version of Vim

vim v9.1.1879

Environment

Os: Arch Linux
Terminal: kitty
$TERM: xterm-kitty
shell: bash 5.3.3

Logs and stack traces


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/18647@github.com>

zeertzjq

unread,
Oct 27, 2025, 3:46:48 AM (4 days ago) Oct 27
to vim/vim, Subscribed
zeertzjq left a comment (vim/vim#18647)

Simple solution:

diff --git a/src/drawscreen.c b/src/drawscreen.c
index 0519940b1..5a339f2ba 100644
--- a/src/drawscreen.c
+++ b/src/drawscreen.c
@@ -2289,7 +2289,7 @@ win_update(win_T *wp)
 	    // Don't scroll when redrawing the top, scrolled already above.
 	    if (lnum == mod_top
 		    && mod_bot != MAXLNUM
-		    && !(dollar_vcol >= 0 && mod_bot == mod_top + 1)
+		    && !(dollar_vcol >= 0)
 		    && row >= top_end)
 	    {
 		int		old_rows = 0;
@@ -2457,6 +2457,11 @@ win_update(win_T *wp)
 		    }
 		}
 	    }
+	    else if (dollar_vcol >= 0 && mod_bot > mod_top + 1)
+		// When dollar_vcol >= 0 the cursor line isn't fully redrawn,
+		// but if other lines need to be redrawn it becomes tricky.
+		// Redraw until the end in this case.
+		mod_bot = MAXLNUM;
 
 #ifdef FEAT_FOLDING
 	    // When lines are folded, display one line for all of them.

No sure if these is a better solution.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/18647/3449911637@github.com>

julio-b

unread,
Oct 27, 2025, 7:45:30 PM (3 days ago) Oct 27
to vim/vim, Subscribed
julio-b left a comment (vim/vim#18647)

Your patch fixes the problem, thank you @zeertzjq !


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/18647/3453814366@github.com>

Christian Brabandt

unread,
Oct 28, 2025, 3:40:07 PM (3 days ago) Oct 28
to vim/vim, Subscribed
chrisbra left a comment (vim/vim#18647)

Thanks both. can your make a PR out of this @zeertzjq (with a test please)?


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/18647/3458186223@github.com>

zeertzjq

unread,
Oct 28, 2025, 4:00:00 PM (3 days ago) Oct 28
to vim/vim, Subscribed
zeertzjq left a comment (vim/vim#18647)

I may try to find another solution, which may take some time.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/18647/3458248961@github.com>

Christian Brabandt

unread,
Oct 29, 2025, 4:20:36 PM (2 days ago) Oct 29
to vim/vim, Subscribed

Closed #18647 as completed via 5c3e762.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issue/18647/issue_event/20590449386@github.com>

Reply all
Reply to author
Forward
0 new messages