mirror of
https://github.com/neovim/neovim.git
synced 2026-01-06 19:39:53 +10:00
test(terminal/mouse_spec): forwarding works with resized grid (#35969)
This commit is contained in:
@@ -930,8 +930,9 @@ int plines_m_win(win_T *wp, linenr_T first, linenr_T last, int max)
|
||||
return MIN(max, count);
|
||||
}
|
||||
|
||||
/// Return number of window lines a physical line range will occupy.
|
||||
/// Only considers real and filler lines.
|
||||
/// Return total number of physical and filler lines in a physical line range.
|
||||
/// Doesn't treat a fold as a single line or consider a wrapped line multiple lines,
|
||||
/// unlike plines_m_win() or win_text_height().
|
||||
///
|
||||
/// Mainly used for calculating scrolling offsets.
|
||||
int plines_m_win_fill(win_T *wp, linenr_T first, linenr_T last)
|
||||
@@ -940,7 +941,7 @@ int plines_m_win_fill(win_T *wp, linenr_T first, linenr_T last)
|
||||
|
||||
if (diffopt_filler()) {
|
||||
for (int lnum = first; lnum <= last; lnum++) {
|
||||
// Note: this also considers folds.
|
||||
// Note: this also considers folds (no filler lines inside folds).
|
||||
int n = diff_check_fill(wp, lnum);
|
||||
count += MAX(n, 0);
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ describe(':terminal mouse', function()
|
||||
|
||||
describe('with mouse events enabled by the program', function()
|
||||
before_each(function()
|
||||
tt.enable_mouse()
|
||||
tt.enable_mouse() -- FIXME: this doesn't work on Windows?
|
||||
tt.feed_data('mouse enabled\n')
|
||||
screen:expect([[
|
||||
line27 |
|
||||
@@ -381,6 +381,87 @@ describe(':terminal mouse', function()
|
||||
|
|
||||
]])
|
||||
end)
|
||||
|
||||
it('mouse forwarding works with resized grid', function()
|
||||
skip(is_os('win'))
|
||||
|
||||
screen:detach()
|
||||
local Screen = require('test.functional.ui.screen')
|
||||
screen = Screen.new(50, 7, { ext_multigrid = true })
|
||||
screen:expect([[
|
||||
## grid 1
|
||||
[2:--------------------------------------------------]|*6
|
||||
[3:--------------------------------------------------]|
|
||||
## grid 2
|
||||
line27 |
|
||||
line28 |
|
||||
line29 |
|
||||
line30 |
|
||||
mouse enabled |
|
||||
^ |
|
||||
## grid 3
|
||||
{5:-- TERMINAL --} |
|
||||
]])
|
||||
|
||||
screen:try_resize_grid(2, 58, 11)
|
||||
screen:expect({ any = vim.pesc('rows: 11, cols: 58') })
|
||||
|
||||
api.nvim_input_mouse('right', 'press', '', 2, 0, 0)
|
||||
screen:expect({ any = vim.pesc('"!!^') })
|
||||
api.nvim_input_mouse('right', 'release', '', 2, 0, 0)
|
||||
screen:expect({ any = vim.pesc('#!!^') })
|
||||
|
||||
api.nvim_input_mouse('right', 'press', '', 2, 10, 0)
|
||||
screen:expect({ any = vim.pesc('"!+^') })
|
||||
api.nvim_input_mouse('right', 'release', '', 2, 10, 0)
|
||||
screen:expect({ any = vim.pesc('#!+^') })
|
||||
|
||||
api.nvim_input_mouse('right', 'press', '', 2, 0, 57)
|
||||
screen:expect({ any = vim.pesc('"Z!^') })
|
||||
api.nvim_input_mouse('right', 'release', '', 2, 0, 57)
|
||||
screen:expect({ any = vim.pesc('#Z!^') })
|
||||
|
||||
api.nvim_input_mouse('right', 'press', '', 2, 10, 57)
|
||||
screen:expect({ any = vim.pesc('"Z+^') })
|
||||
api.nvim_input_mouse('right', 'release', '', 2, 10, 57)
|
||||
screen:expect({ any = vim.pesc('#Z+^') })
|
||||
|
||||
command('setlocal winbar=WINBAR')
|
||||
screen:expect({ any = vim.pesc(('{5:WINBAR%s}'):format((' '):rep(52))) })
|
||||
eq('t', api.nvim_get_mode().mode)
|
||||
|
||||
api.nvim_input_mouse('right', 'press', '', 2, 0, 0)
|
||||
eq('nt', api.nvim_get_mode().mode)
|
||||
api.nvim_input_mouse('right', 'release', '', 2, 0, 0)
|
||||
feed('i')
|
||||
eq('t', api.nvim_get_mode().mode)
|
||||
|
||||
api.nvim_input_mouse('right', 'press', '', 2, 0, 57)
|
||||
eq('nt', api.nvim_get_mode().mode)
|
||||
api.nvim_input_mouse('right', 'release', '', 2, 0, 57)
|
||||
feed('i')
|
||||
eq('t', api.nvim_get_mode().mode)
|
||||
|
||||
api.nvim_input_mouse('right', 'press', '', 2, 1, 0)
|
||||
screen:expect({ any = vim.pesc('"!!^') })
|
||||
api.nvim_input_mouse('right', 'release', '', 2, 1, 0)
|
||||
screen:expect({ any = vim.pesc('#!!^') })
|
||||
|
||||
api.nvim_input_mouse('right', 'press', '', 2, 10, 0)
|
||||
screen:expect({ any = vim.pesc('"!*^') })
|
||||
api.nvim_input_mouse('right', 'release', '', 2, 10, 0)
|
||||
screen:expect({ any = vim.pesc('#!*^') })
|
||||
|
||||
api.nvim_input_mouse('right', 'press', '', 2, 1, 57)
|
||||
screen:expect({ any = vim.pesc('"Z!^') })
|
||||
api.nvim_input_mouse('right', 'release', '', 2, 1, 57)
|
||||
screen:expect({ any = vim.pesc('#Z!^') })
|
||||
|
||||
api.nvim_input_mouse('right', 'press', '', 2, 10, 57)
|
||||
screen:expect({ any = vim.pesc('"Z*^') })
|
||||
api.nvim_input_mouse('right', 'release', '', 2, 10, 57)
|
||||
screen:expect({ any = vim.pesc('#Z*^') })
|
||||
end)
|
||||
end)
|
||||
|
||||
describe('with a split window and other buffer', function()
|
||||
|
||||
Reference in New Issue
Block a user