mirror of
https://github.com/neovim/neovim
synced 2025-07-17 01:31:48 +00:00
fix(extmark): fix missing virt_lines when using id param of set_extmark
This commit is contained in:
@ -68,6 +68,14 @@ uint64_t extmark_set(buf_T *buf, uint64_t ns_id, uint64_t *idp, int row, colnr_T
|
|||||||
uint64_t mark = 0;
|
uint64_t mark = 0;
|
||||||
uint64_t id = idp ? *idp : 0;
|
uint64_t id = idp ? *idp : 0;
|
||||||
|
|
||||||
|
uint8_t decor_level = kDecorLevelNone; // no decor
|
||||||
|
if (decor) {
|
||||||
|
decor_level = kDecorLevelVisible; // decor affects redraw
|
||||||
|
if (kv_size(decor->virt_lines)) {
|
||||||
|
decor_level = kDecorLevelVirtLine; // decor affects horizontal size
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (id == 0) {
|
if (id == 0) {
|
||||||
id = ns->free_id++;
|
id = ns->free_id++;
|
||||||
} else {
|
} else {
|
||||||
@ -76,7 +84,6 @@ uint64_t extmark_set(buf_T *buf, uint64_t ns_id, uint64_t *idp, int row, colnr_T
|
|||||||
if (old_mark & MARKTREE_PAIRED_FLAG || end_row > -1) {
|
if (old_mark & MARKTREE_PAIRED_FLAG || end_row > -1) {
|
||||||
extmark_del(buf, ns_id, id);
|
extmark_del(buf, ns_id, id);
|
||||||
} else {
|
} else {
|
||||||
// TODO(bfredl): we need to do more if "revising" a decoration mark.
|
|
||||||
MarkTreeIter itr[1] = { 0 };
|
MarkTreeIter itr[1] = { 0 };
|
||||||
old_pos = marktree_lookup(buf->b_marktree, old_mark, itr);
|
old_pos = marktree_lookup(buf->b_marktree, old_mark, itr);
|
||||||
assert(itr->node);
|
assert(itr->node);
|
||||||
@ -86,7 +93,7 @@ uint64_t extmark_set(buf_T *buf, uint64_t ns_id, uint64_t *idp, int row, colnr_T
|
|||||||
if (it.decor) {
|
if (it.decor) {
|
||||||
decor_remove(buf, row, row, it.decor);
|
decor_remove(buf, row, row, it.decor);
|
||||||
}
|
}
|
||||||
mark = marktree_revise(buf->b_marktree, itr);
|
mark = marktree_revise(buf->b_marktree, itr, decor_level);
|
||||||
goto revised;
|
goto revised;
|
||||||
}
|
}
|
||||||
marktree_del_itr(buf->b_marktree, itr, false);
|
marktree_del_itr(buf->b_marktree, itr, false);
|
||||||
@ -96,14 +103,6 @@ uint64_t extmark_set(buf_T *buf, uint64_t ns_id, uint64_t *idp, int row, colnr_T
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t decor_level = kDecorLevelNone; // no decor
|
|
||||||
if (decor) {
|
|
||||||
decor_level = kDecorLevelVisible; // decor affects redraw
|
|
||||||
if (kv_size(decor->virt_lines)) {
|
|
||||||
decor_level = kDecorLevelVirtLine; // decor affects horizontal size
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (end_row > -1) {
|
if (end_row > -1) {
|
||||||
mark = marktree_put_pair(buf->b_marktree,
|
mark = marktree_put_pair(buf->b_marktree,
|
||||||
row, col, right_gravity,
|
row, col, right_gravity,
|
||||||
|
@ -570,11 +570,11 @@ void marktree_free_node(mtnode_t *x)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// NB: caller must check not pair!
|
/// NB: caller must check not pair!
|
||||||
uint64_t marktree_revise(MarkTree *b, MarkTreeIter *itr)
|
uint64_t marktree_revise(MarkTree *b, MarkTreeIter *itr, uint8_t decor_level)
|
||||||
{
|
{
|
||||||
uint64_t old_id = rawkey(itr).id;
|
uint64_t old_id = rawkey(itr).id;
|
||||||
pmap_del(uint64_t)(b->id2node, ANTIGRAVITY(old_id));
|
pmap_del(uint64_t)(b->id2node, ANTIGRAVITY(old_id));
|
||||||
uint64_t new_id = (b->next_id += ID_INCR);
|
uint64_t new_id = (b->next_id += ID_INCR) + ((uint64_t)decor_level << DECOR_OFFSET);
|
||||||
rawkey(itr).id = new_id + (RIGHT_GRAVITY&old_id);
|
rawkey(itr).id = new_id + (RIGHT_GRAVITY&old_id);
|
||||||
refkey(b, itr->node, itr->i);
|
refkey(b, itr->node, itr->i);
|
||||||
return new_id;
|
return new_id;
|
||||||
|
@ -992,7 +992,7 @@ if (h->n_buckets < new_n_buckets) { // expand
|
|||||||
]]}
|
]]}
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('works with text et the end of the buffer', function()
|
it('works with text at the end of the buffer', function()
|
||||||
insert(example_text)
|
insert(example_text)
|
||||||
feed 'G'
|
feed 'G'
|
||||||
|
|
||||||
@ -1213,7 +1213,7 @@ if (h->n_buckets < new_n_buckets) { // expand
|
|||||||
|
|
|
|
||||||
]]}
|
]]}
|
||||||
|
|
||||||
meths.buf_set_extmark(0, ns, 2, 0, {
|
local markid = meths.buf_set_extmark(0, ns, 2, 0, {
|
||||||
virt_lines={
|
virt_lines={
|
||||||
{{"Some special", "Special"}};
|
{{"Some special", "Special"}};
|
||||||
{{"remark about codes", "Comment"}};
|
{{"remark about codes", "Comment"}};
|
||||||
@ -1235,13 +1235,13 @@ if (h->n_buckets < new_n_buckets) { // expand
|
|||||||
|
|
|
|
||||||
]]}
|
]]}
|
||||||
|
|
||||||
meths.buf_clear_namespace(0, ns, 0, -1)
|
|
||||||
meths.buf_set_extmark(0, ns, 2, 0, {
|
meths.buf_set_extmark(0, ns, 2, 0, {
|
||||||
virt_lines={
|
virt_lines={
|
||||||
{{"Some special", "Special"}};
|
{{"Some special", "Special"}};
|
||||||
{{"remark about codes", "Comment"}};
|
{{"remark about codes", "Comment"}};
|
||||||
};
|
};
|
||||||
virt_lines_leftcol=true;
|
virt_lines_leftcol=true;
|
||||||
|
id=markid;
|
||||||
})
|
})
|
||||||
screen:expect{grid=[[
|
screen:expect{grid=[[
|
||||||
{8: }{9: 1 }^if (h->n_buckets < new_n_buckets) { // expan|
|
{8: }{9: 1 }^if (h->n_buckets < new_n_buckets) { // expan|
|
||||||
|
Reference in New Issue
Block a user