neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit b840b5b6a94411a456123306adca715683e16bba
parent 8a9ab88945cdabcbd23f23406353ec6110fefa83
Author: bfredl <bjorn.linse@gmail.com>
Date:   Wed, 18 May 2022 19:55:01 +0200

Merge pull request #18624 from famiu/feat/ui/winbar

fix(ui): set correct position on mouse click when 'winbar' is enabled
Diffstat:
Msrc/nvim/mouse.c | 3+++
Mtest/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 @@ -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 @@ -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)