patch 9.1.2102: foldtext not reversed and cut off in 'rightleft' mode
Commit:
https://github.com/vim/vim/commit/b51ac5e378892f085ef6b86f607be4faa2100788
Author: Sergey Vlasov <[email protected]>
Date: Wed Jan 21 19:48:46 2026 +0000
patch 9.1.2102: foldtext not reversed and cut off in 'rightleft' mode
Problem: foldtext not reversed and cut off in 'rightleft' mode
(bfredl)
Solution: Fix the rightleft redrawing logic (Sergey Vlasov)
fixes: #2659
closes: #19220
Signed-off-by: Sergey Vlasov <[email protected]>
Signed-off-by: Christian Brabandt <[email protected]>
diff --git a/src/drawscreen.c b/src/drawscreen.c
index 79c0483e1..112484081 100644
--- a/src/drawscreen.c
+++ b/src/drawscreen.c
@@ -898,12 +898,12 @@ text_to_screenline(win_T *wp, char_u *text, int col)
{
cells = (*mb_ptr2cells)(p);
c_len = (*mb_ptr2len)(p);
- if (col + cells > wp->w_width
+ if (col + cells > wp->w_width)
+ break;
# ifdef FEAT_RIGHTLEFT
- - (wp->w_p_rl ? col : 0)
+ if (wp->w_p_rl)
+ idx = off + wp->w_width - col - cells;
# endif
- )
- break;
ScreenLines[idx] = *p;
if (enc_utf8)
{
@@ -1270,35 +1270,33 @@ fold_line(
col = text_to_screenline(wp, text, col);
// Fill the rest of the line with the fold filler
-# ifdef FEAT_RIGHTLEFT
- if (wp->w_p_rl)
- col -= txtcol;
-# endif
- while (col < wp->w_width
-# ifdef FEAT_RIGHTLEFT
- - (wp->w_p_rl ? txtcol : 0)
-# endif
- )
+ while (col < wp->w_width)
{
int c = wp->w_fill_chars.fold;
+ int idx = off + col;
+
+# ifdef FEAT_RIGHTLEFT
+ if (wp->w_p_rl)
+ idx = off + wp->w_width - 1 - col;
+# endif
if (enc_utf8)
{
if (c >= 0x80)
{
- ScreenLinesUC[off + col] = c;
- ScreenLinesC[0][off + col] = 0;
- ScreenLines[off + col] = 0x80; // avoid storing zero
+ ScreenLinesUC[idx] = c;
+ ScreenLinesC[0][idx] = 0;
+ ScreenLines[idx] = 0x80; // avoid storing zero
}
else
{
- ScreenLinesUC[off + col] = 0;
- ScreenLines[off + col] = c;
+ ScreenLinesUC[idx] = 0;
+ ScreenLines[idx] = c;
}
- col++;
}
else
- ScreenLines[off + col++] = c;
+ ScreenLines[idx] = c;
+ ++col;
}
if (text != buf)
diff --git a/src/testdir/dumps/Test_foldtext_and_fillchars_rightleft_01.dump
b/src/testdir/dumps/Test_foldtext_and_fillchars_rightleft_01.dump
new file mode 100644
index 000000000..b1892c0ed
--- /dev/null
+++ b/src/testdir/dumps/Test_foldtext_and_fillchars_rightleft_01.dump
@@ -0,0 +1,5 @@
+|-+0#0000e05#a8a8a8255@5|g|n|i|c|s|i|p|i|d|a| |r|u|t|e|t|c|e|s|n|o|c|
|,|t|e|m|a| |t|i|s| |r|o|l|o|d| |m|u|s|p|i| |m|e|r|o|L| |:|s|e|n|i|l| |2|
@1|-@1>+
+| +0#0000000#ffffff0@19|g|n|i|c|s|i|p|i|d|a| |r|u|t|e|t|c|e|s|n|o|c|
|,|t|e|m|a| |t|i|s| |r|o|l|o|d| |m|u|s|p|i| |m|e|r|o|L
+| +0#4040ff13&@68|~
+| @68|~
+| +0#0000000&@51|1|,|1| @10|A|l@1|
diff --git a/src/testdir/dumps/Test_foldtext_and_fillchars_rightleft_02.dump
b/src/testdir/dumps/Test_foldtext_and_fillchars_rightleft_02.dump
new file mode 100644
index 000000000..1f401ec6d
--- /dev/null
+++ b/src/testdir/dumps/Test_foldtext_and_fillchars_rightleft_02.dump
@@ -0,0 +1,5 @@
+|-+0#0000e05#a8a8a8255@7|t*&|e|m|a| +&|t*&|i|s| +&|r*&|o|l|o|d|
+&|m*&|u|s|p|i| +&|m*&|e|r|o|L| +&|:|s|e|n|i|l| |2| @1|->-|+
+| +0#0000000#ffffff0@21|t*&|e|m|a| +&|t*&|i|s| +&|r*&|o|l|o|d| +&|m*&|u|s|p|i|
+&|m*&|e|r|o|L
+| +0#4040ff13&@68|~
+| @68|~
+|:+0#0000000&|c|a|l@1| |s|e|t|l|i|n|e|(|1|,| |[|g|:|m|u|l|t|i|b|y|t|e|,|
|g|:|m|u|l|t|i|b|y|t|e|,| |g|:|m|u|l|t|i|b|1|,|1| @10|A|l@1|
diff --git a/src/testdir/test_fold.vim b/src/testdir/test_fold.vim
index 5ba2e81f3..56b6aaece 100644
--- a/src/testdir/test_fold.vim
+++ b/src/testdir/test_fold.vim
@@ -1473,6 +1473,54 @@ func Test_foldtextresult()
bw!
endfunc
+" Test for foldtext and fillchars with 'rightleft' enabled
+func Test_foldtext_and_fillchars_rightleft()
+ CheckFeature rightleft
+ CheckScreendump
+ CheckRunVimInTerminal
+
+ let script_lines =<< trim END
+ let longtext = 'Lorem ipsum dolor sit amet, consectetur adipiscing'
+ let g:multibyte = 'Lorem ipsum dolor sit amet'
+
+ call setline(1, [longtext, longtext, longtext])
+ 1,2fold
+
+ setlocal rightleft
+ set noshowmode noshowcmd
+ END
+ call writefile(script_lines, 'XTest_foldtext_and_fillchars_rightleft', 'D')
+ let buf = RunVimInTerminal('-S XTest_foldtext_and_fillchars_rightleft',
{'rows': 5, 'cols': 70})
+
+ call VerifyScreenDump(buf, 'Test_foldtext_and_fillchars_rightleft_01', {})
+ call term_sendkeys(buf, ":call setline(1, [g:multibyte, g:multibyte,
g:multibyte])\<CR>")
+ call VerifyScreenDump(buf, 'Test_foldtext_and_fillchars_rightleft_02', {})
+
+ " clean up
+ call StopVimInTerminal(buf)
+endfunc
+
+" Test for foldtextresult() with 'rightleft' enabled
+func Test_foldtextresult_rightleft()
+ CheckFeature rightleft
+
+ new
+ set columns=70
+ setlocal rightleft
+
+ let longtext = 'Lorem ipsum dolor sit amet, consectetur adipiscing'
+ let multibyte = 'Lorem ipsum dolor sit amet'
+
+ call setline(1, [longtext, longtext, longtext])
+ 1,2fold
+ call assert_equal('+-- 2 lines: ' .. longtext, foldtextresult(1))
+
+ call setline(1, [multibyte, multibyte, multibyte])
+ call assert_equal('+-- 2 lines: ' .. multibyte, foldtextresult(1))
+
+ bw!
+endfunc
+
" Test for merging two recursive folds when an intermediate line with no fold
" is removed
func Test_fold_merge_recursive()
diff --git a/src/version.c b/src/version.c
index d6644bf10..b893c9ad2 100644
--- a/src/version.c
+++ b/src/version.c
@@ -734,6 +734,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 2102,
/**/
2101,
/**/
--
--
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 [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/vim_dev/E1vieN3-006yNK-PS%40256bit.org.