aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nvim/drawline.c19
-rw-r--r--src/nvim/grid_defs.h2
-rw-r--r--src/nvim/mouse.c12
3 files changed, 20 insertions, 13 deletions
diff --git a/src/nvim/drawline.c b/src/nvim/drawline.c
index 73021d83a8..65c400299d 100644
--- a/src/nvim/drawline.c
+++ b/src/nvim/drawline.c
@@ -3024,14 +3024,17 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool number_onl
linebuf_attr[wlv.off] = wlv.char_attr;
}
- linebuf_vcol[wlv.off] = wlv.vcol;
-
- if (wlv.draw_state == WL_FOLD) {
- linebuf_vcol[wlv.off] = -2;
+ if (wlv.draw_state > WL_STC && wlv.filler_todo <= 0) {
+ linebuf_vcol[wlv.off] = wlv.vcol;
+ } else if (wlv.draw_state == WL_FOLD) {
if (wlv.n_closing > 0) {
linebuf_vcol[wlv.off] = -3;
wlv.n_closing--;
+ } else {
+ linebuf_vcol[wlv.off] = -2;
}
+ } else {
+ linebuf_vcol[wlv.off] = -1;
}
if (utf_char2cells(mb_c) > 1) {
@@ -3041,17 +3044,19 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool number_onl
// UTF-8: Put a 0 in the second screen char.
linebuf_char[wlv.off] = 0;
linebuf_attr[wlv.off] = linebuf_attr[wlv.off - 1];
+
if (wlv.draw_state > WL_STC && wlv.filler_todo <= 0) {
- wlv.vcol++;
+ linebuf_vcol[wlv.off] = ++wlv.vcol;
+ } else {
+ linebuf_vcol[wlv.off] = -1;
}
+
// When "wlv.tocol" is halfway through a character, set it to the end
// of the character, otherwise highlighting won't stop.
if (wlv.tocol == wlv.vcol) {
wlv.tocol++;
}
- linebuf_vcol[wlv.off] = wlv.vcol;
-
if (wp->w_p_rl) {
// now it's time to backup one cell
wlv.off--;
diff --git a/src/nvim/grid_defs.h b/src/nvim/grid_defs.h
index 207bf72816..100d648263 100644
--- a/src/nvim/grid_defs.h
+++ b/src/nvim/grid_defs.h
@@ -44,7 +44,7 @@ enum {
/// attrs[] contains the highlighting attribute for each cell.
///
/// vcols[] contains the virtual columns in the line. -1 means not available
-/// (below last line), MAXCOL means after the end of the line.
+/// or before buffer text, MAXCOL means after the end of the line.
/// -2 or -3 means in fold column and a mouse click should:
/// -2: open a fold
/// -3: close a fold
diff --git a/src/nvim/mouse.c b/src/nvim/mouse.c
index 33d7bc2e51..9b09a3fdf3 100644
--- a/src/nvim/mouse.c
+++ b/src/nvim/mouse.c
@@ -1890,13 +1890,15 @@ static void mouse_check_grid(colnr_T *vcolp, int *flagsp)
}
colnr_T eol_vcol = gp->vcols[off_r];
assert(eol_vcol < MAXCOL);
- // This may be -2 or -3 with 'foldcolumn' and empty line.
- // In that case set it to -1 as it's just before start of line.
- eol_vcol = MAX(eol_vcol, -1);
+ if (eol_vcol < 0) {
+ // Empty line or whole line before w_leftcol,
+ // with columns before buffer text
+ eol_vcol = wp->w_leftcol - 1;
+ }
*vcolp = eol_vcol + (int)(off - off_r);
} else {
- // Clicking on an empty line
- *vcolp = click_col - start_col;
+ // Empty line or whole line before w_leftcol
+ *vcolp = click_col - start_col + wp->w_leftcol;
}
} else if (col_from_screen >= 0) {
// Use the virtual column from vcols[], it is accurate also after