{
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)
{
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)
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()