compositor: handle float overlapping left half of doublewidth char

This commit is contained in:
Björn Linse 2019-07-09 14:46:31 +02:00
parent 42bdccdf6c
commit 4af1ada9ef
2 changed files with 91 additions and 7 deletions

View File

@ -290,10 +290,14 @@ static void compose_line(Integer row, Integer startcol, Integer endcol,
{
// in case we start on the right half of a double-width char, we need to
// check the left half. But skip it in output if it wasn't doublewidth.
int skip = 0;
int skipstart = 0, skipend = 0;
if (startcol > 0 && (flags & kLineFlagInvalid)) {
startcol--;
skip = 1;
skipstart = 1;
}
if (endcol < default_grid.Columns && (flags & kLineFlagInvalid)) {
endcol++;
skipend = 1;
}
int col = (int)startcol;
@ -345,20 +349,27 @@ static void compose_line(Integer row, Integer startcol, Integer endcol,
if (linebuf[col-startcol][0] == NUL) {
linebuf[col-startcol][0] = ' ';
linebuf[col-startcol][1] = NUL;
if (col == endcol-1) {
skipend = 0;
}
} else if (n > 1 && linebuf[col-startcol+1][0] == NUL) {
skip = 0;
skipstart = 0;
}
if (grid->comp_col+grid->Columns > until
&& grid->chars[off+n][0] == NUL) {
linebuf[until-1-startcol][0] = ' ';
linebuf[until-1-startcol][1] = '\0';
if (col == startcol && n == 1) {
skip = 0;
skipstart = 0;
}
}
col = until;
}
if (linebuf[endcol-startcol-1][0] == NUL) {
skipend = 0;
}
assert(endcol <= chk_width);
assert(row < chk_height);
@ -368,9 +379,10 @@ static void compose_line(Integer row, Integer startcol, Integer endcol,
flags = flags & ~kLineFlagWrap;
}
ui_composed_call_raw_line(1, row, startcol+skip, endcol, endcol, 0, flags,
(const schar_T *)linebuf+skip,
(const sattr_T *)attrbuf+skip);
ui_composed_call_raw_line(1, row, startcol+skipstart,
endcol-skipend, endcol-skipend, 0, flags,
(const schar_T *)linebuf+skipstart,
(const sattr_T *)attrbuf+skipstart);
}
static void compose_area(Integer startrow, Integer endrow,

View File

@ -4473,6 +4473,78 @@ describe('floating windows', function()
]])
end
end)
it('can overlap doublewidth chars', function()
insert([[
# TODO:
# FIXME: ]])
local buf = meths.create_buf(false,false)
local win = meths.open_win(buf, false, {relative='editor', width=5, height=3, row=0, col=11, style='minimal'})
if multigrid then
screen:expect{grid=[[
## grid 1
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
|
## grid 2
# TODO: |
# FIXME: ^ |
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
## grid 3
{1: }|
{1: }|
{1: }|
]], float_pos={ [3] = { { id = 1001 }, "NW", 1, 0, 11, true } }}
else
screen:expect([[
# TODO: {1: } |
# FIXME: {1: } ^ |
{0:~ }{1: }{0: }|
{0:~ }|
{0:~ }|
{0:~ }|
|
]])
end
meths.win_close(win, false)
if multigrid then
screen:expect([[
## grid 1
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
|
## grid 2
# TODO: |
# FIXME: ^ |
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
]])
else
screen:expect([[
# TODO: |
# FIXME: ^ |
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
|
]])
end
end)
end
describe('with ext_multigrid', function()