summaryrefslogtreecommitdiffstats
path: root/src/drawscreen.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-03-03 13:26:02 +0100
committerBram Moolenaar <Bram@vim.org>2021-03-03 13:26:02 +0100
commit4fa1175765d55613302fc27d0f65e2c699452b6e (patch)
treec1322ae51aab567c43386d082fd91d52ff1c786b /src/drawscreen.c
parent37096afd3f3133a831ab49a9677f090c3c935c9d (diff)
patch 8.2.2563: cannot use multibyte characters for folding in 'fillchars'v8.2.2563
Problem: Cannot use multibyte characters for folding in 'fillchars'. Solution: Port pull request 11568 to Vim. (Yegappan Lakshmanan, closes #7924)
Diffstat (limited to 'src/drawscreen.c')
-rw-r--r--src/drawscreen.c74
1 files changed, 50 insertions, 24 deletions
diff --git a/src/drawscreen.c b/src/drawscreen.c
index 3fe1c0c797..c2752bdd8a 100644
--- a/src/drawscreen.c
+++ b/src/drawscreen.c
@@ -1044,7 +1044,9 @@ fold_line(
linenr_T lnum,
int row)
{
- char_u buf[FOLD_TEXT_LEN];
+ // Max value of 'foldcolumn' is 12 and maximum number of bytes in a
+ // multi-byte character is MAX_MCO.
+ char_u buf[MAX_MCO * 12 + 1];
pos_T *top, *bot;
linenr_T lnume = lnum + fold_count - 1;
int len;
@@ -1077,29 +1079,6 @@ fold_line(
}
#endif
- // 2. Add the 'foldcolumn'
- // Reduce the width when there is not enough space.
- fdc = compute_foldcolumn(wp, col);
- if (fdc > 0)
- {
- fill_foldcolumn(buf, wp, TRUE, lnum);
-#ifdef FEAT_RIGHTLEFT
- if (wp->w_p_rl)
- {
- int i;
-
- copy_text_attr(off + wp->w_width - fdc - col, buf, fdc,
- HL_ATTR(HLF_FC));
- // reverse the fold column
- for (i = 0; i < fdc; ++i)
- ScreenLines[off + wp->w_width - i - 1 - col] = buf[i];
- }
- else
-#endif
- copy_text_attr(off + col, buf, fdc, HL_ATTR(HLF_FC));
- col += fdc;
- }
-
#ifdef FEAT_RIGHTLEFT
# define RL_MEMSET(p, v, l) \
do { \
@@ -1118,6 +1097,53 @@ fold_line(
} while (0)
#endif
+ // 2. Add the 'foldcolumn'
+ // Reduce the width when there is not enough space.
+ fdc = compute_foldcolumn(wp, col);
+ if (fdc > 0)
+ {
+ char_u *p;
+ int i;
+ int idx;
+
+ fill_foldcolumn(buf, wp, TRUE, lnum);
+ p = buf;
+ for (i = 0; i < fdc; i++)
+ {
+ int ch;
+
+ if (has_mbyte)
+ ch = mb_ptr2char_adv(&p);
+ else
+ ch = *p++;
+#ifdef FEAT_RIGHTLEFT
+ if (wp->w_p_rl)
+ idx = off + wp->w_width - i - 1 - col;
+ else
+#endif
+ idx = off + col + i;
+ if (enc_utf8)
+ {
+ if (ch >= 0x80)
+ {
+ ScreenLinesUC[idx] = ch;
+ ScreenLinesC[0][idx] = 0;
+ ScreenLines[idx] = 0x80;
+ }
+ else
+ {
+ ScreenLines[idx] = ch;
+ ScreenLinesUC[idx] = 0;
+ }
+ }
+ else
+ ScreenLines[idx] = ch;
+ }
+
+ RL_MEMSET(col, HL_ATTR(HLF_FC), fdc);
+ col += fdc;
+ }
+
// Set all attributes of the 'number' or 'relativenumber' column and the
// text
RL_MEMSET(col, HL_ATTR(HLF_FL), wp->w_width - col);