mirror of
https://github.com/neovim/neovim.git
synced 2025-10-06 18:06:30 +00:00
fix(extmarks): properly handle virt_text on next screen line (#25166)
TODO: virt_text_hide doesn't work for the first char on a wrapped screen line, and it's not clear how to fix that.
This commit is contained in:
@@ -348,18 +348,12 @@ next_mark:
|
||||
if (active && item.decor.spell != kNone) {
|
||||
spell = item.decor.spell;
|
||||
}
|
||||
if (item.start_row == state->row && decor_virt_pos(&item.decor)
|
||||
&& item.draw_col != INT_MIN) {
|
||||
if (item.start_col <= col) {
|
||||
if (item.decor.virt_text_pos == kVTOverlay && item.draw_col == -1) {
|
||||
item.draw_col = (item.decor.virt_text_hide && hidden) ? INT_MIN : win_col;
|
||||
} else if (item.draw_col == -3) {
|
||||
item.draw_col = -1;
|
||||
}
|
||||
} else if (wp->w_p_wrap
|
||||
&& (item.decor.virt_text_pos == kVTRightAlign
|
||||
|| item.decor.virt_text_pos == kVTWinCol)) {
|
||||
item.draw_col = -3;
|
||||
if (item.start_row == state->row && item.start_col <= col
|
||||
&& decor_virt_pos(&item.decor) && item.draw_col == -1) {
|
||||
if (item.decor.virt_text_pos == kVTOverlay) {
|
||||
item.draw_col = (item.decor.virt_text_hide && hidden) ? INT_MIN : win_col;
|
||||
} else if (win_col < 0 && item.decor.virt_text_pos != kVTInline) {
|
||||
item.draw_col = win_col;
|
||||
}
|
||||
}
|
||||
if (keep) {
|
||||
|
@@ -84,7 +84,8 @@ typedef struct {
|
||||
bool virt_text_owned;
|
||||
/// Screen column to draw the virtual text.
|
||||
/// When -1, the virtual text may be drawn after deciding where.
|
||||
/// When -3, the virtual text should be drawn on a later screen line.
|
||||
/// When -2, the virtual text should be drawn at the start of the screen line.
|
||||
/// When -3, the virtual text should be drawn on the next screen line.
|
||||
/// When INT_MIN, the virtual text should no longer be drawn.
|
||||
int draw_col;
|
||||
uint64_t ns_id;
|
||||
|
@@ -282,6 +282,10 @@ static void draw_virt_text(win_T *wp, buf_T *buf, int col_off, int *end_col, int
|
||||
} else if (item->decor.virt_text_pos == kVTWinCol) {
|
||||
item->draw_col = MAX(item->decor.col + col_off, 0);
|
||||
}
|
||||
} else if (item->draw_col == -2) {
|
||||
item->draw_col = col_off;
|
||||
} else if (item->draw_col == -3) {
|
||||
item->draw_col = item->decor.virt_text_pos == kVTOverlay ? -2 : -1;
|
||||
}
|
||||
if (item->draw_col < 0) {
|
||||
continue;
|
||||
@@ -3080,10 +3084,16 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool number_onl
|
||||
|
||||
if (has_decor && (wp->w_p_rl ? (wlv.col < 0) : (wlv.col >= grid->cols))) {
|
||||
// At the end of screen line: might need to peek for decorations just after
|
||||
// this position. Without wrapping, we might need to display win_col overlays
|
||||
// from the entire text line.
|
||||
colnr_T nextpos = wp->w_p_wrap ? (colnr_T)(ptr - line) : (colnr_T)strlen(line);
|
||||
decor_redraw_col(wp, nextpos, wlv.off, true, &decor_state);
|
||||
// this position.
|
||||
if (wp->w_p_wrap) {
|
||||
// FIXME: virt_text_hide doesn't work for overlay virt_text at the next char
|
||||
// as it's not easy to check if the next char is inside Visual selection.
|
||||
decor_redraw_col(wp, (int)(ptr - line), -3, false, &decor_state);
|
||||
} else {
|
||||
// Without wrapping, we might need to display right_align and win_col
|
||||
// virt_text for the entire text line.
|
||||
decor_redraw_col(wp, MAXCOL, -1, true, &decor_state);
|
||||
}
|
||||
}
|
||||
|
||||
// At end of screen line and there is more to come: Display the line
|
||||
|
Reference in New Issue
Block a user