diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-03-31 08:40:17 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-31 08:40:17 +0800 |
commit | 0d4bd420c19e3a81b494ec1f58cffde53d9b84ea (patch) | |
tree | 3d24efcdc4b103687629a04f9e9edb4d2165275f | |
parent | 6d648f5594d580766fb28e45d797a4019d8b8149 (diff) | |
download | rneovim-0d4bd420c19e3a81b494ec1f58cffde53d9b84ea.tar.gz rneovim-0d4bd420c19e3a81b494ec1f58cffde53d9b84ea.tar.bz2 rneovim-0d4bd420c19e3a81b494ec1f58cffde53d9b84ea.zip |
fix: correct vertical dragging room calculation with global statusline (#17928)
This fixes the bug that win_move_statusline() or mouse dragging cannot
reduce 'cmdheight' to 1 when global statusline is used.
-rw-r--r-- | src/nvim/window.c | 4 | ||||
-rw-r--r-- | test/functional/ui/global_statusline_spec.lua | 27 |
2 files changed, 29 insertions, 2 deletions
diff --git a/src/nvim/window.c b/src/nvim/window.c index 6bd2ef3ef6..632e9b3f44 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -5857,11 +5857,11 @@ void win_drag_status_line(win_T *dragwin, int offset) } else { // drag down up = false; // Only dragging the last status line can reduce p_ch. - room = Rows - cmdline_row - global_stl_height(); + room = Rows - cmdline_row; if (curfr->fr_next == NULL) { room -= 1; } else { - room -= p_ch; + room -= p_ch + global_stl_height(); } if (room < 0) { room = 0; diff --git a/test/functional/ui/global_statusline_spec.lua b/test/functional/ui/global_statusline_spec.lua index 6b37e5e2f1..f6821ec589 100644 --- a/test/functional/ui/global_statusline_spec.lua +++ b/test/functional/ui/global_statusline_spec.lua @@ -1,6 +1,7 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') local clear, command, feed = helpers.clear, helpers.command, helpers.feed +local eq, funcs, meths = helpers.eq, helpers.funcs, helpers.meths describe('global statusline', function() local screen @@ -230,4 +231,30 @@ describe('global statusline', function() [3] = {reverse = true, bold = true}; }} end) + + it('win_move_statusline() can reduce cmdheight to 1', function() + eq(1, meths.get_option('cmdheight')) + funcs.win_move_statusline(0, -1) + eq(2, meths.get_option('cmdheight')) + funcs.win_move_statusline(0, -1) + eq(3, meths.get_option('cmdheight')) + funcs.win_move_statusline(0, 1) + eq(2, meths.get_option('cmdheight')) + funcs.win_move_statusline(0, 1) + eq(1, meths.get_option('cmdheight')) + end) + + it('mouse dragging can reduce cmdheight to 1', function() + command('set mouse=a') + meths.input_mouse('left', 'press', '', 0, 14, 10) + eq(1, meths.get_option('cmdheight')) + meths.input_mouse('left', 'drag', '', 0, 13, 10) + eq(2, meths.get_option('cmdheight')) + meths.input_mouse('left', 'drag', '', 0, 12, 10) + eq(3, meths.get_option('cmdheight')) + meths.input_mouse('left', 'drag', '', 0, 13, 10) + eq(2, meths.get_option('cmdheight')) + meths.input_mouse('left', 'drag', '', 0, 14, 10) + eq(1, meths.get_option('cmdheight')) + end) end) |