Fix trimming of line front halfway through a double-width glyph

Insert a space to replace the half glyph and ensure the rest of the
line is correctly aligned.

Fixes #4843
This commit is contained in:
Maxime Coste 2023-02-15 13:04:53 +11:00
parent 0630b4f4f6
commit afaa47e93f
5 changed files with 15 additions and 2 deletions

View File

@ -253,14 +253,18 @@ bool DisplayLine::trim_from(ColumnCount first_col, ColumnCount front, ColumnCoun
}
auto front_it = it;
Face last_face{};
while (front > 0 and it != end())
{
front -= it->trim_begin(front);
kak_assert(it->empty() or front == 0);
kak_assert(it->empty() or front <= 0);
last_face = it->face;
if (it->empty())
++it;
}
m_atoms.erase(front_it, it);
it = m_atoms.erase(front_it, it);
if (front < 0)
it = m_atoms.insert(it, DisplayAtom{String{' ', -front}, last_face});
it = begin();
for (; it != end() and col_count > 0; ++it)

View File

@ -0,0 +1 @@
lvl

View File

@ -0,0 +1,4 @@
abc
⌛c
⌛d
⌛e

View File

@ -0,0 +1,2 @@
add-highlighter window/ regex d 0:green
add-highlighter window/ regex ^[^\n]+e 0:yellow

View File

@ -0,0 +1,2 @@
ui_out -ignore 1
ui_out '{ "jsonrpc": "2.0", "method": "draw", "params": [[[{ "face": { "fg": "black", "bg": "white", "underline": "default", "attributes": [] }, "contents": "b" }, { "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "c\u000a" }], [{ "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": " " }, { "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "c\u000a" }], [{ "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": " " }, { "face": { "fg": "green", "bg": "default", "underline": "default", "attributes": [] }, "contents": "d" }, { "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "\u000a" }], [{ "face": { "fg": "yellow", "bg": "default", "underline": "default", "attributes": [] }, "contents": " " }, { "face": { "fg": "yellow", "bg": "default", "underline": "default", "attributes": [] }, "contents": "e" }, { "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "\u000a" }]], { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, { "fg": "blue", "bg": "default", "underline": "default", "attributes": [] }] }'