aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-06-15 09:03:39 +0800
committerGitHub <noreply@github.com>2023-06-15 09:03:39 +0800
commita05bbc60eaf2d18cb117345becd9d2d13fa4ce4c (patch)
tree4859fbae57f8a8f96a068df49fefe1fc1a319a2b /src
parent78d77c03de579845fcaa761e7339c93fcd74efb2 (diff)
downloadrneovim-a05bbc60eaf2d18cb117345becd9d2d13fa4ce4c.tar.gz
rneovim-a05bbc60eaf2d18cb117345becd9d2d13fa4ce4c.tar.bz2
rneovim-a05bbc60eaf2d18cb117345becd9d2d13fa4ce4c.zip
fix(extmarks): don't position overlay virt_text halfway a char (#24027)
Diffstat (limited to 'src')
-rw-r--r--src/nvim/drawline.c87
1 files changed, 39 insertions, 48 deletions
diff --git a/src/nvim/drawline.c b/src/nvim/drawline.c
index eb5de14f32..7da8bfae14 100644
--- a/src/nvim/drawline.c
+++ b/src/nvim/drawline.c
@@ -871,10 +871,6 @@ 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)
{
- 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
@@ -1763,50 +1759,10 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool number_onl
break;
}
- if (wlv.draw_state == WL_LINE
- && has_fold
- && wlv.col == win_col_offset
- && wlv.n_extra == 0
- && wlv.row == startrow + wlv.filler_lines) {
+ const bool draw_folded = wlv.draw_state == WL_LINE && has_fold
+ && wlv.row == startrow + wlv.filler_lines;
+ if (draw_folded && wlv.n_extra == 0) {
wlv.char_attr = folded_attr = win_hl_attr(wp, HLF_FL);
-
- linenr_T lnume = lnum + foldinfo.fi_lines - 1;
- memset(buf_fold, ' ', FOLD_TEXT_LEN);
- wlv.p_extra = get_foldtext(wp, lnum, lnume, foldinfo, buf_fold);
- wlv.n_extra = (int)strlen(wlv.p_extra);
-
- if (wlv.p_extra != buf_fold) {
- xfree(wlv.p_extra_free);
- wlv.p_extra_free = wlv.p_extra;
- }
- wlv.c_extra = NUL;
- wlv.c_final = NUL;
- wlv.p_extra[wlv.n_extra] = NUL;
-
- // Get the line again as evaluating 'foldtext' may free it.
- line = ml_get_buf(wp->w_buffer, lnum, false);
- ptr = line + v;
- }
-
- if (wlv.draw_state == WL_LINE
- && has_fold
- && wlv.col < grid->cols
- && wlv.n_extra == 0
- && wlv.row == startrow + wlv.filler_lines) {
- // fill rest of line with 'fold'
- wlv.c_extra = wp->w_p_fcs_chars.fold;
- wlv.c_final = NUL;
-
- wlv.n_extra = wp->w_p_rl ? (wlv.col + 1) : (grid->cols - wlv.col);
- }
-
- if (wlv.draw_state == WL_LINE
- && has_fold
- && wlv.col >= grid->cols
- && wlv.n_extra != 0
- && wlv.row == startrow + wlv.filler_lines) {
- // Truncate the folding.
- wlv.n_extra = 0;
}
int extmark_attr = 0;
@@ -1829,7 +1785,11 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool number_onl
area_active = false;
}
- if (has_decor && v >= 0) {
+ if (wlv.n_extra == 0 || !wlv.extra_for_extmark) {
+ wlv.reset_extra_attr = false;
+ }
+
+ if (has_decor && v >= 0 && wlv.n_extra == 0) {
bool selected = (area_active || (area_highlighting && noinvcur
&& wlv.vcol == wp->w_virtcol));
extmark_attr = decor_redraw_col(wp, (colnr_T)v, wlv.off, selected, &decor_state);
@@ -1919,6 +1879,37 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool number_onl
}
}
+ if (draw_folded && wlv.n_extra == 0 && wlv.col == win_col_offset) {
+ linenr_T lnume = lnum + foldinfo.fi_lines - 1;
+ memset(buf_fold, ' ', FOLD_TEXT_LEN);
+ wlv.p_extra = get_foldtext(wp, lnum, lnume, foldinfo, buf_fold);
+ wlv.n_extra = (int)strlen(wlv.p_extra);
+
+ if (wlv.p_extra != buf_fold) {
+ xfree(wlv.p_extra_free);
+ wlv.p_extra_free = wlv.p_extra;
+ }
+ wlv.c_extra = NUL;
+ wlv.c_final = NUL;
+ wlv.p_extra[wlv.n_extra] = NUL;
+
+ // Get the line again as evaluating 'foldtext' may free it.
+ line = ml_get_buf(wp->w_buffer, lnum, false);
+ ptr = line + v;
+ }
+
+ if (draw_folded && wlv.n_extra == 0 && wlv.col < grid->cols) {
+ // Fill rest of line with 'fold'.
+ wlv.c_extra = wp->w_p_fcs_chars.fold;
+ wlv.c_final = NUL;
+ wlv.n_extra = wp->w_p_rl ? (wlv.col + 1) : (grid->cols - wlv.col);
+ }
+
+ if (draw_folded && wlv.n_extra != 0 && wlv.col >= grid->cols) {
+ // Truncate the folding.
+ wlv.n_extra = 0;
+ }
+
// Get the next character to put on the screen.
//
// The "p_extra" points to the extra stuff that is inserted to