aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-06-13 11:30:19 +0800
committerGitHub <noreply@github.com>2023-06-13 11:30:19 +0800
commit4c7cec4e293495e69c105f883905f78af4c151c0 (patch)
tree639a7fdcbe7cea8ac41effd61a587724f86ae166 /src
parenta7e5d4238a00d5bfa5809b2860047eca2d565e62 (diff)
downloadrneovim-4c7cec4e293495e69c105f883905f78af4c151c0.tar.gz
rneovim-4c7cec4e293495e69c105f883905f78af4c151c0.tar.bz2
rneovim-4c7cec4e293495e69c105f883905f78af4c151c0.zip
fix(extmarks): handle inline virt_text with empty chunk (#24005)
Diffstat (limited to 'src')
-rw-r--r--src/nvim/drawline.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/src/nvim/drawline.c b/src/nvim/drawline.c
index 280c1d6994..eb5de14f32 100644
--- a/src/nvim/drawline.c
+++ b/src/nvim/drawline.c
@@ -871,9 +871,15 @@ static void apply_cursorline_highlight(win_T *wp, winlinevars_T *wlv)
static void handle_inline_virtual_text(win_T *wp, winlinevars_T *wlv, ptrdiff_t v, bool *do_save)
{
- while (true) {
- // we could already be inside an existing inline text with multiple chunks
- if (!(wlv->virt_inline_i < kv_size(wlv->virt_inline))) {
+ if (wlv->n_extra == 0 || !wlv->extra_for_extmark) {
+ wlv->reset_extra_attr = false;
+ }
+
+ while (wlv->n_extra == 0) {
+ if (wlv->virt_inline_i >= kv_size(wlv->virt_inline)) {
+ // need to find inline virtual text
+ wlv->virt_inline = VIRTTEXT_EMPTY;
+ wlv->virt_inline_i = 0;
DecorState *state = &decor_state;
for (size_t i = 0; i < kv_size(state->active); i++) {
DecorRange *item = &kv_A(state->active, i);
@@ -884,18 +890,16 @@ static void handle_inline_virtual_text(win_T *wp, winlinevars_T *wlv, ptrdiff_t
}
if (item->draw_col >= -1 && item->start_col == v) {
wlv->virt_inline = item->decor.virt_text;
- wlv->virt_inline_i = 0;
item->draw_col = INT_MIN;
break;
}
}
- }
-
- if (wlv->n_extra == 0 || !wlv->extra_for_extmark) {
- wlv->reset_extra_attr = false;
- }
-
- if (wlv->n_extra <= 0 && wlv->virt_inline_i < kv_size(wlv->virt_inline)) {
+ if (!kv_size(wlv->virt_inline)) {
+ // no more inline virtual text here
+ break;
+ }
+ } else {
+ // already inside existing inline virtual text with multiple chunks
VirtTextChunk vtc = kv_A(wlv->virt_inline, wlv->virt_inline_i);
wlv->p_extra = vtc.text;
wlv->n_extra = (int)strlen(wlv->p_extra);
@@ -932,7 +936,6 @@ static void handle_inline_virtual_text(win_T *wp, winlinevars_T *wlv, ptrdiff_t
}
}
}
- break;
}
}