aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/mouse.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-03-17 07:26:39 +0800
committerGitHub <noreply@github.com>2024-03-17 07:26:39 +0800
commitd114dbe9f79c1382298b04319b7ded88e95e3ee8 (patch)
treea3ed5239b72332bef8e42afa2b9ba095c74d7afe /src/nvim/mouse.c
parent34b57508a78b0a980e898ee35d950db0a90368ca (diff)
downloadrneovim-d114dbe9f79c1382298b04319b7ded88e95e3ee8.tar.gz
rneovim-d114dbe9f79c1382298b04319b7ded88e95e3ee8.tar.bz2
rneovim-d114dbe9f79c1382298b04319b7ded88e95e3ee8.zip
vim-patch:9.1.0184: Cursor pos wrong when clicking with conceal and wrap (#27890)
Problem: Cursor position wrong when clicking with conceal and wrap. Solution: Use the virtual column of the last char for ScreenCols[] in boguscols. Remove use of MAXCOL in ScreenCols[]. Rename third argument of wlv_screen_line() to "clear_end" as that's clearer what it does (zeertzjq). related: 14192 closes: vim/vim#14200 https://github.com/vim/vim/commit/d0c1b7723f7e73763597af2f97a53d94ab7ed020 Rename win_put_linebuf() to wlv_put_linebuf().
Diffstat (limited to 'src/nvim/mouse.c')
-rw-r--r--src/nvim/mouse.c28
1 files changed, 1 insertions, 27 deletions
diff --git a/src/nvim/mouse.c b/src/nvim/mouse.c
index d82ba58918..a2b4042f30 100644
--- a/src/nvim/mouse.c
+++ b/src/nvim/mouse.c
@@ -1883,33 +1883,7 @@ static void mouse_check_grid(colnr_T *vcolp, int *flagsp)
const size_t off = gp->line_offset[click_row] + (size_t)click_col;
colnr_T col_from_screen = gp->vcols[off];
- if (col_from_screen == MAXCOL) {
- // When clicking after end of line, still need to set correct curswant
- size_t off_l = gp->line_offset[click_row] + (size_t)start_col;
- if (gp->vcols[off_l] < MAXCOL) {
- // Binary search to find last char in line
- size_t off_r = off;
- while (off_l < off_r) {
- size_t off_m = (off_l + off_r + 1) / 2;
- if (gp->vcols[off_m] < MAXCOL) {
- off_l = off_m;
- } else {
- off_r = off_m - 1;
- }
- }
- colnr_T eol_vcol = gp->vcols[off_r];
- assert(eol_vcol < MAXCOL);
- if (eol_vcol < 0) {
- // Empty line or whole line before w_leftcol,
- // with columns before buffer text
- eol_vcol = curwin->w_leftcol - 1;
- }
- *vcolp = eol_vcol + (int)(off - off_r);
- } else {
- // Empty line or whole line before w_leftcol
- *vcolp = click_col - start_col + curwin->w_leftcol;
- }
- } else if (col_from_screen >= 0) {
+ if (col_from_screen >= 0) {
// Use the virtual column from vcols[], it is accurate also after
// concealed characters.
*vcolp = col_from_screen;