diff options
author | Famiu Haque <famiuhaque@protonmail.com> | 2022-05-18 21:15:34 +0600 |
---|---|---|
committer | Famiu Haque <famiuhaque@protonmail.com> | 2022-05-18 21:15:34 +0600 |
commit | 288819c9cc8620fdb749721618bd43c479a9e500 (patch) | |
tree | 38d449683cf14d9682726bdddf3b0987fde5eb93 | |
parent | d7dd6007167eac919205404bc4e556237118a7a7 (diff) | |
download | rneovim-288819c9cc8620fdb749721618bd43c479a9e500.tar.gz rneovim-288819c9cc8620fdb749721618bd43c479a9e500.tar.bz2 rneovim-288819c9cc8620fdb749721618bd43c479a9e500.zip |
fix(ui): set correct position on mouse click when 'winbar' is enabled
-rw-r--r-- | src/nvim/mouse.c | 3 | ||||
-rw-r--r-- | test/functional/ui/winbar_spec.lua | 17 |
2 files changed, 20 insertions, 0 deletions
diff --git a/src/nvim/mouse.c b/src/nvim/mouse.c index 3a1cc6b557..ad17bfc8a9 100644 --- a/src/nvim/mouse.c +++ b/src/nvim/mouse.c @@ -406,6 +406,9 @@ bool mouse_comp_pos(win_T *win, int *rowp, int *colp, linenr_T *lnump) if (win->w_p_rl) { col = win->w_width_inner - 1 - col; } + if (win->w_winbar_height) { + row -= win->w_winbar_height; + } lnum = win->w_topline; diff --git a/test/functional/ui/winbar_spec.lua b/test/functional/ui/winbar_spec.lua index 6cf587d47b..abc6088801 100644 --- a/test/functional/ui/winbar_spec.lua +++ b/test/functional/ui/winbar_spec.lua @@ -2,6 +2,9 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') local clear = helpers.clear local command = helpers.command +local insert = helpers.insert +local meths = helpers.meths +local eq = helpers.eq describe('winbar', function() local screen @@ -177,4 +180,18 @@ describe('winbar', function() | ]]) end) + it('sets correct position on mouse click', function() + insert[[ + line 1 + line 2 + line 3 + line 4 + line -42 + line i + line sin(theta) + line 8 + ]] + meths.input_mouse('left', 'press', '', 0, 5, 1) + eq({5, 1}, meths.win_get_cursor(0)) + end) end) |