summaryrefslogtreecommitdiff
path: root/src/terminal.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-11-06 17:58:35 +0100
committerBram Moolenaar <Bram@vim.org>2020-11-06 17:58:35 +0100
commit927495b1fef835a8f83c089bb3aa3608b617e972 (patch)
treeb6b5eb8a5e0ca9bcb15a0e078b4dcff9929b5ceb /src/terminal.c
parent32e5ec0b017adb68fe36adb9a9a362abdaffe7f4 (diff)
downloadvim-git-927495b1fef835a8f83c089bb3aa3608b617e972.tar.gz
patch 8.2.1963: crash when using a popup window with "latin1" encodingv8.2.1963
Problem: Crash when using a popup window with "latin1" encoding. Solution: Don't use ScreenLinesUC when enc_utf8 is false. (closes #7241)
Diffstat (limited to 'src/terminal.c')
-rw-r--r--src/terminal.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/terminal.c b/src/terminal.c
index ff3e3bd6a..e81754cca 100644
--- a/src/terminal.c
+++ b/src/terminal.c
@@ -1830,6 +1830,10 @@ update_snapshot(term_T *term)
width = cell.width;
cell2cellattr(&cell, &p[pos.col]);
+ if (width == 2)
+ // second cell of double-width character has the
+ // same attributes.
+ p[pos.col + 1] = p[pos.col];
// Each character can be up to 6 bytes.
if (ga_grow(&ga, VTERM_MAX_CHARS_PER_CELL * 6) == OK)
@@ -3639,6 +3643,7 @@ term_line2screenline(
}
#endif
else
+ // This will only store the lower byte of "c".
ScreenLines[off] = c;
}
ScreenAttrs[off] = cell2attr(term, wp, cell.attrs, cell.fg, cell.bg);
@@ -3647,13 +3652,20 @@ term_line2screenline(
++off;
if (cell.width == 2)
{
- if (enc_utf8)
- ScreenLinesUC[off] = NUL;
-
// don't set the second byte to NUL for a DBCS encoding, it
// has been set above
- if (enc_utf8 || !has_mbyte)
+ if (enc_utf8)
+ {
+ ScreenLinesUC[off] = NUL;
ScreenLines[off] = NUL;
+ }
+ else if (!has_mbyte)
+ {
+ // Can't show a double-width character with a single-byte
+ // 'encoding', just use a space.
+ ScreenLines[off] = ' ';
+ ScreenAttrs[off] = ScreenAttrs[off - 1];
+ }
++pos->col;
++off;