aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-09-22 05:44:45 +0800
committerGitHub <noreply@github.com>2023-09-22 05:44:45 +0800
commit6555176f34f102a8878a0bac55fd80459c943aa2 (patch)
treeecb102dd40dd82231bfeb98b5fef3e0ccdb0d179 /src
parentc1ff21666862237d41d80c4a07529457439380ad (diff)
downloadrneovim-6555176f34f102a8878a0bac55fd80459c943aa2.tar.gz
rneovim-6555176f34f102a8878a0bac55fd80459c943aa2.tar.bz2
rneovim-6555176f34f102a8878a0bac55fd80459c943aa2.zip
vim-patch:9.0.1923: curswant wrong on click with 've' and 'nowrap' set (#25293)
Problem: curswant wrong on click with 've' and 'nowrap' set Solution: Add w_leftcol to mouse click column. closes: vim/vim#13142 https://github.com/vim/vim/commit/db54e989b5cff3cc6442dfc500e3962cc1c0b6d0
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