mirror of
https://github.com/neovim/neovim.git
synced 2024-12-24 13:15:09 -07:00
fix(extmarks): fix win_col virt_text drawn on wrong screen line (#25264)
This commit is contained in:
parent
877d04d0fb
commit
818d7f6daf
@ -254,7 +254,7 @@ static void decor_add(DecorState *state, int start_row, int start_col, int end_r
|
|||||||
|
|
||||||
DecorRange range = { start_row, start_col, end_row, end_col,
|
DecorRange range = { start_row, start_col, end_row, end_col,
|
||||||
*decor, attr_id,
|
*decor, attr_id,
|
||||||
kv_size(decor->virt_text) && owned, -1, ns_id, mark_id };
|
kv_size(decor->virt_text) && owned, -10, ns_id, mark_id };
|
||||||
|
|
||||||
kv_pushp(state->active);
|
kv_pushp(state->active);
|
||||||
size_t index;
|
size_t index;
|
||||||
@ -268,10 +268,10 @@ static void decor_add(DecorState *state, int start_row, int start_col, int end_r
|
|||||||
kv_A(state->active, index) = range;
|
kv_A(state->active, index) = range;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Initialize the draw_col of a newly-added non-inline virtual text item.
|
/// Initialize the draw_col of a newly-added virtual text item.
|
||||||
static void decor_init_draw_col(int win_col, bool hidden, DecorRange *item)
|
static void decor_init_draw_col(int win_col, bool hidden, DecorRange *item)
|
||||||
{
|
{
|
||||||
if (win_col < 0) {
|
if (win_col < 0 && item->decor.virt_text_pos != kVTInline) {
|
||||||
item->draw_col = win_col;
|
item->draw_col = win_col;
|
||||||
} else if (item->decor.virt_text_pos == kVTOverlay) {
|
} else if (item->decor.virt_text_pos == kVTOverlay) {
|
||||||
item->draw_col = (item->decor.virt_text_hide && hidden) ? INT_MIN : win_col;
|
item->draw_col = (item->decor.virt_text_hide && hidden) ? INT_MIN : win_col;
|
||||||
@ -371,8 +371,7 @@ next_mark:
|
|||||||
spell = item.decor.spell;
|
spell = item.decor.spell;
|
||||||
}
|
}
|
||||||
if (item.start_row == state->row && item.start_col <= col
|
if (item.start_row == state->row && item.start_col <= col
|
||||||
&& decor_virt_pos(&item.decor) && item.draw_col == -1
|
&& decor_virt_pos(&item.decor) && item.draw_col == -10) {
|
||||||
&& item.decor.virt_text_pos != kVTInline) {
|
|
||||||
decor_init_draw_col(win_col, hidden, &item);
|
decor_init_draw_col(win_col, hidden, &item);
|
||||||
}
|
}
|
||||||
if (keep) {
|
if (keep) {
|
||||||
|
@ -85,6 +85,7 @@ typedef struct {
|
|||||||
/// Screen column to draw the virtual text.
|
/// Screen column to draw the virtual text.
|
||||||
/// When -1, the virtual text may be drawn after deciding where.
|
/// When -1, the virtual text may be drawn after deciding where.
|
||||||
/// When -3, the virtual text should be drawn on the next screen line.
|
/// When -3, the virtual text should be drawn on the next screen line.
|
||||||
|
/// When -10, the virtual text has just been added.
|
||||||
/// When INT_MIN, the virtual text should no longer be drawn.
|
/// When INT_MIN, the virtual text should no longer be drawn.
|
||||||
int draw_col;
|
int draw_col;
|
||||||
uint64_t ns_id;
|
uint64_t ns_id;
|
||||||
|
@ -1237,6 +1237,25 @@ describe('extmark decorations', function()
|
|||||||
|
|
|
|
||||||
]]}
|
]]}
|
||||||
|
|
||||||
|
meths.buf_set_extmark(0, ns, 4, 50, { virt_text={{'EOL', 'NonText'}} })
|
||||||
|
screen:expect{grid=[[
|
||||||
|
for _,item in ipairs(items) do |
|
||||||
|
local text, hl_id_cell, cou{4:Very} unpack(ite{4:VERY}|
|
||||||
|
if |
|
||||||
|
hl_id_cell ~= nil then {4:Much} {4:MUCH}|
|
||||||
|
--^ -- -- -- -- -- -- --{4:Error}- -- hl_i{4:ERROR}|
|
||||||
|
l_id_cell {1:EOL} |
|
||||||
|
end |
|
||||||
|
for _ = 1, (count or 1) do |
|
||||||
|
local cell = line[colpos] |
|
||||||
|
{1:-} cell.text = text {1:-}|
|
||||||
|
cell.hl_id = hl_id |
|
||||||
|
colpos = colpos+1 |
|
||||||
|
end |
|
||||||
|
end |
|
||||||
|
|
|
||||||
|
]]}
|
||||||
|
|
||||||
feed '.'
|
feed '.'
|
||||||
screen:expect{grid=[[
|
screen:expect{grid=[[
|
||||||
for _,item in ipairs(items) do |
|
for _,item in ipairs(items) do |
|
||||||
@ -1244,7 +1263,7 @@ describe('extmark decorations', function()
|
|||||||
if |
|
if |
|
||||||
hl_id_cell ~= nil then {4:Much} {4:MUCH}|
|
hl_id_cell ~= nil then {4:Much} {4:MUCH}|
|
||||||
--^ -- -- -- -- -- -- -- -- -- -- -- hl_id |
|
--^ -- -- -- -- -- -- -- -- -- -- -- hl_id |
|
||||||
= hl_id_cell {4:Error} {4:ERROR}|
|
= hl_id_cell {1:EOL} {4:Error} {4:ERROR}|
|
||||||
end |
|
end |
|
||||||
for _ = 1, (count or 1) do |
|
for _ = 1, (count or 1) do |
|
||||||
local cell = line[colpos] |
|
local cell = line[colpos] |
|
||||||
@ -1264,7 +1283,7 @@ describe('extmark decorations', function()
|
|||||||
{2: 3 } if |
|
{2: 3 } if |
|
||||||
{2: 4 }hl_id_cell ~= nil then {4:Much} {4:MUCH}|
|
{2: 4 }hl_id_cell ~= nil then {4:Much} {4:MUCH}|
|
||||||
{2: 5 } --^ -- -- -- -- -- -- -- -- -- -- -- hl|
|
{2: 5 } --^ -- -- -- -- -- -- -- -- -- -- -- hl|
|
||||||
{2: }_id = hl_id_cell {4:Error} {4:ERROR}|
|
{2: }_id = hl_id_cell {1:EOL} {4:Error} {4:ERROR}|
|
||||||
{2: 6 } end |
|
{2: 6 } end |
|
||||||
{2: 7 } for _ = 1, (count or 1) do |
|
{2: 7 } for _ = 1, (count or 1) do |
|
||||||
{2: 8 } local cell = line[colpos] |
|
{2: 8 } local cell = line[colpos] |
|
||||||
@ -1283,7 +1302,7 @@ describe('extmark decorations', function()
|
|||||||
{2: 3 } if |
|
{2: 3 } if |
|
||||||
{2: 4 }hl_id_cell ~= nil then {4:Much} {4:MUCH}|
|
{2: 4 }hl_id_cell ~= nil then {4:Much} {4:MUCH}|
|
||||||
{2: 5 } --^ -- -- -- -- -- -- -- -- -- -- -- hl|
|
{2: 5 } --^ -- -- -- -- -- -- -- -- -- -- -- hl|
|
||||||
_id = hl_id_cell {4:Error} {4:ERROR}|
|
_id = hl_id_cell {1:EOL} {4:Error} {4:ERROR}|
|
||||||
{2: 6 } end |
|
{2: 6 } end |
|
||||||
{2: 7 } for _ = 1, (count or 1) do |
|
{2: 7 } for _ = 1, (count or 1) do |
|
||||||
{2: 8 } local cell = line[colpos] |
|
{2: 8 } local cell = line[colpos] |
|
||||||
|
Loading…
Reference in New Issue
Block a user