Mercurial > vim
comparison src/mouse.c @ 31154:7e48ddb8b079 v9.0.0911
patch 9.0.0911: with 'smoothscroll' set mouse click position may be wrong
Commit: https://github.com/vim/vim/commit/e6392b102151ec69fad232bcf00591230cef8e1c
Author: Yee Cheng Chin <ychin.git@gmail.com>
Date: Sat Nov 19 14:31:08 2022 +0000
patch 9.0.0911: with 'smoothscroll' set mouse click position may be wrong
Problem: With 'smoothscroll' set mouse click position may be wrong.
Solution: Adjust computations for w_skipcol. (Yee Cheng Chin, closes https://github.com/vim/vim/issues/11514)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 19 Nov 2022 15:45:03 +0100 |
parents | 388ef91ae4f5 |
children | a86ee6c0309e |
comparison
equal
deleted
inserted
replaced
31153:cd02a3926498 | 31154:7e48ddb8b079 |
---|---|
3032 { | 3032 { |
3033 if (lnum == win->w_topline) | 3033 if (lnum == win->w_topline) |
3034 row -= win->w_topfill; | 3034 row -= win->w_topfill; |
3035 else | 3035 else |
3036 row -= diff_check_fill(win, lnum); | 3036 row -= diff_check_fill(win, lnum); |
3037 count = plines_win_nofill(win, lnum, TRUE); | 3037 count = plines_win_nofill(win, lnum, FALSE); |
3038 } | 3038 } |
3039 else | 3039 else |
3040 #endif | 3040 #endif |
3041 count = plines_win(win, lnum, TRUE); | 3041 count = plines_win(win, lnum, FALSE); |
3042 if (plines_cache != NULL && cache_idx < Rows) | 3042 if (plines_cache != NULL && cache_idx < Rows) |
3043 plines_cache[cache_idx] = count; | 3043 plines_cache[cache_idx] = count; |
3044 } | 3044 } |
3045 | |
3046 if (win->w_skipcol > 0 && lnum == win->w_topline) | |
3047 { | |
3048 // Adjust for 'smoothscroll' clipping the top screen lines. | |
3049 // A similar formula is used in curs_columns(). | |
3050 int width1 = win->w_width - win_col_off(win); | |
3051 int skip_lines = 0; | |
3052 if (win->w_skipcol > width1) | |
3053 skip_lines = (win->w_skipcol - width1) | |
3054 / (width1 + win_col_off2(win)) + 1; | |
3055 else if (win->w_skipcol > 0) | |
3056 skip_lines = 1; | |
3057 count -= skip_lines; | |
3058 } | |
3059 | |
3045 if (count > row) | 3060 if (count > row) |
3046 break; // Position is in this buffer line. | 3061 break; // Position is in this buffer line. |
3047 #ifdef FEAT_FOLDING | 3062 #ifdef FEAT_FOLDING |
3048 (void)hasFoldingWin(win, lnum, NULL, &lnum, TRUE, NULL); | 3063 (void)hasFoldingWin(win, lnum, NULL, &lnum, TRUE, NULL); |
3049 #endif | 3064 #endif |
3061 // Compute the column without wrapping. | 3076 // Compute the column without wrapping. |
3062 off = win_col_off(win) - win_col_off2(win); | 3077 off = win_col_off(win) - win_col_off2(win); |
3063 if (col < off) | 3078 if (col < off) |
3064 col = off; | 3079 col = off; |
3065 col += row * (win->w_width - off); | 3080 col += row * (win->w_width - off); |
3066 // add skip column (for long wrapping line) | 3081 |
3067 col += win->w_skipcol; | 3082 // Add skip column for the topline. |
3083 if (lnum == win->w_topline) | |
3084 col += win->w_skipcol; | |
3068 } | 3085 } |
3069 | 3086 |
3070 if (!win->w_p_wrap) | 3087 if (!win->w_p_wrap) |
3071 col += win->w_leftcol; | 3088 col += win->w_leftcol; |
3072 | 3089 |