mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
fix(statusline): also allow right click when 'mousemodel' is "popup*"
Problem: The 'statusline'-format ui elements do not receive right
click events when "mousemodel" is "popup*"
Solution: Do not draw popupmenu and handle click event instead.
(cherry picked from commit 6b5b6e5e07
)
This commit is contained in:

committed by
github-actions[bot]
![github-actions[bot]](/assets/img/avatar_default.png)
parent
0c8e2d128e
commit
f24449d35c
@@ -212,24 +212,33 @@ static int get_fpos_of_mouse(pos_T *mpos)
|
|||||||
if (wp == NULL) {
|
if (wp == NULL) {
|
||||||
return IN_UNKNOWN;
|
return IN_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
int winrow = row;
|
||||||
|
int wincol = col;
|
||||||
|
|
||||||
|
// compute the position in the buffer line from the posn on the screen
|
||||||
|
bool below_buffer = mouse_comp_pos(wp, &row, &col, &mpos->lnum);
|
||||||
|
|
||||||
|
if (!below_buffer && *wp->w_p_stc != NUL && mouse_col < win_col_off(wp)) {
|
||||||
|
return MOUSE_STATUSCOL;
|
||||||
|
}
|
||||||
|
|
||||||
// winpos and height may change in win_enter()!
|
// winpos and height may change in win_enter()!
|
||||||
if (row + wp->w_winbar_height >= wp->w_height) { // In (or below) status line
|
if (winrow + wp->w_winbar_height >= wp->w_height) { // In (or below) status line
|
||||||
return IN_STATUS_LINE;
|
return IN_STATUS_LINE;
|
||||||
}
|
}
|
||||||
if (col >= wp->w_width) { // In vertical separator line
|
|
||||||
|
if (winrow == -1 && wp->w_winbar_height != 0) {
|
||||||
|
return MOUSE_WINBAR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (wincol >= wp->w_width) { // In vertical separator line
|
||||||
return IN_SEP_LINE;
|
return IN_SEP_LINE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wp != curwin) {
|
if (wp != curwin || below_buffer) {
|
||||||
return IN_UNKNOWN;
|
return IN_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
// compute the position in the buffer line from the posn on the screen
|
|
||||||
if (mouse_comp_pos(curwin, &row, &col, &mpos->lnum)) {
|
|
||||||
return IN_STATUS_LINE; // past bottom
|
|
||||||
}
|
|
||||||
|
|
||||||
mpos->col = vcol2col(wp, mpos->lnum, col);
|
mpos->col = vcol2col(wp, mpos->lnum, col);
|
||||||
|
|
||||||
mpos->coladd = 0;
|
mpos->coladd = 0;
|
||||||
@@ -530,6 +539,11 @@ bool do_mouse(oparg_T *oap, int c, int dir, long count, bool fixindent)
|
|||||||
// shift-left button -> right button
|
// shift-left button -> right button
|
||||||
// alt-left button -> alt-right button
|
// alt-left button -> alt-right button
|
||||||
if (mouse_model_popup()) {
|
if (mouse_model_popup()) {
|
||||||
|
pos_T m_pos;
|
||||||
|
int m_pos_flag = get_fpos_of_mouse(&m_pos);
|
||||||
|
if (m_pos_flag & (IN_STATUS_LINE|MOUSE_WINBAR|MOUSE_STATUSCOL)) {
|
||||||
|
goto popupexit;
|
||||||
|
}
|
||||||
if (which_button == MOUSE_RIGHT
|
if (which_button == MOUSE_RIGHT
|
||||||
&& !(mod_mask & (MOD_MASK_SHIFT | MOD_MASK_CTRL))) {
|
&& !(mod_mask & (MOD_MASK_SHIFT | MOD_MASK_CTRL))) {
|
||||||
if (!is_click) {
|
if (!is_click) {
|
||||||
@@ -539,17 +553,14 @@ bool do_mouse(oparg_T *oap, int c, int dir, long count, bool fixindent)
|
|||||||
}
|
}
|
||||||
jump_flags = 0;
|
jump_flags = 0;
|
||||||
if (strcmp(p_mousem, "popup_setpos") == 0) {
|
if (strcmp(p_mousem, "popup_setpos") == 0) {
|
||||||
// First set the cursor position before showing the popup
|
// First set the cursor position before showing the popup menu.
|
||||||
// menu.
|
|
||||||
if (VIsual_active) {
|
if (VIsual_active) {
|
||||||
pos_T m_pos;
|
// set MOUSE_MAY_STOP_VIS if we are outside the selection
|
||||||
// set MOUSE_MAY_STOP_VIS if we are outside the
|
// or the current window (might have false negative here)
|
||||||
// selection or the current window (might have false
|
|
||||||
// negative here)
|
|
||||||
if (mouse_row < curwin->w_winrow
|
if (mouse_row < curwin->w_winrow
|
||||||
|| mouse_row > (curwin->w_winrow + curwin->w_height)) {
|
|| mouse_row > (curwin->w_winrow + curwin->w_height)) {
|
||||||
jump_flags = MOUSE_MAY_STOP_VIS;
|
jump_flags = MOUSE_MAY_STOP_VIS;
|
||||||
} else if (get_fpos_of_mouse(&m_pos) != IN_BUFFER) {
|
} else if (m_pos_flag != IN_BUFFER) {
|
||||||
jump_flags = MOUSE_MAY_STOP_VIS;
|
jump_flags = MOUSE_MAY_STOP_VIS;
|
||||||
} else {
|
} else {
|
||||||
if (VIsual_mode == 'V') {
|
if (VIsual_mode == 'V') {
|
||||||
@@ -593,6 +604,7 @@ bool do_mouse(oparg_T *oap, int c, int dir, long count, bool fixindent)
|
|||||||
mod_mask &= ~MOD_MASK_SHIFT;
|
mod_mask &= ~MOD_MASK_SHIFT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
popupexit:
|
||||||
|
|
||||||
if ((State & (MODE_NORMAL | MODE_INSERT))
|
if ((State & (MODE_NORMAL | MODE_INSERT))
|
||||||
&& !(mod_mask & (MOD_MASK_SHIFT | MOD_MASK_CTRL))) {
|
&& !(mod_mask & (MOD_MASK_SHIFT | MOD_MASK_CTRL))) {
|
||||||
@@ -644,7 +656,7 @@ bool do_mouse(oparg_T *oap, int c, int dir, long count, bool fixindent)
|
|||||||
in_sep_line = (jump_flags & IN_SEP_LINE);
|
in_sep_line = (jump_flags & IN_SEP_LINE);
|
||||||
|
|
||||||
if ((in_winbar || in_status_line || in_statuscol) && is_click) {
|
if ((in_winbar || in_status_line || in_statuscol) && is_click) {
|
||||||
// Handle click event on window bar or status lin
|
// Handle click event on window bar, status line or status column
|
||||||
int click_grid = mouse_grid;
|
int click_grid = mouse_grid;
|
||||||
int click_row = mouse_row;
|
int click_row = mouse_row;
|
||||||
int click_col = mouse_col;
|
int click_col = mouse_col;
|
||||||
@@ -672,7 +684,7 @@ bool do_mouse(oparg_T *oap, int c, int dir, long count, bool fixindent)
|
|||||||
call_click_def_func(click_defs, click_col, which_button);
|
call_click_def_func(click_defs, click_col, which_button);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
assert(false && "winbar and statusline only support %@ for clicks");
|
assert(false && "winbar, statusline and statuscolumn only support %@ for clicks");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1840,16 +1840,6 @@ describe('ui/mouse/input', function()
|
|||||||
eq({2, 9}, meths.win_get_cursor(0))
|
eq({2, 9}, meths.win_get_cursor(0))
|
||||||
eq('', funcs.getreg('"'))
|
eq('', funcs.getreg('"'))
|
||||||
|
|
||||||
-- Try clicking on the status line
|
|
||||||
funcs.setreg('"', '')
|
|
||||||
meths.win_set_cursor(0, {1, 9})
|
|
||||||
feed('vee')
|
|
||||||
meths.input_mouse('right', 'press', '', 0, 5, 1)
|
|
||||||
meths.input_mouse('right', 'release', '', 0, 5, 1)
|
|
||||||
feed('<Down><CR>')
|
|
||||||
eq({1, 9}, meths.win_get_cursor(0))
|
|
||||||
eq('ran away', funcs.getreg('"'))
|
|
||||||
|
|
||||||
-- Try clicking outside the window
|
-- Try clicking outside the window
|
||||||
funcs.setreg('"', '')
|
funcs.setreg('"', '')
|
||||||
meths.win_set_cursor(0, {2, 1})
|
meths.win_set_cursor(0, {2, 1})
|
||||||
|
@@ -9,6 +9,8 @@ local feed = helpers.feed
|
|||||||
local meths = helpers.meths
|
local meths = helpers.meths
|
||||||
local pcall_err = helpers.pcall_err
|
local pcall_err = helpers.pcall_err
|
||||||
|
|
||||||
|
local mousemodels = { "extend", "popup", "popup_setpos" }
|
||||||
|
|
||||||
describe('statuscolumn', function()
|
describe('statuscolumn', function()
|
||||||
local screen
|
local screen
|
||||||
before_each(function()
|
before_each(function()
|
||||||
@@ -420,45 +422,47 @@ describe('statuscolumn', function()
|
|||||||
]])
|
]])
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it("works with 'statuscolumn' clicks", function()
|
for _, model in ipairs(mousemodels) do
|
||||||
command('set mousemodel=extend')
|
it("works with 'statuscolumn' clicks with mousemodel=" .. model, function()
|
||||||
command([[
|
command('set mousemodel=' .. model)
|
||||||
function! MyClickFunc(minwid, clicks, button, mods)
|
command([[
|
||||||
let g:testvar = printf("%d %d %s %d", a:minwid, a:clicks, a:button, getmousepos().line)
|
function! MyClickFunc(minwid, clicks, button, mods)
|
||||||
if a:mods !=# ' '
|
let g:testvar = printf("%d %d %s %d", a:minwid, a:clicks, a:button, getmousepos().line)
|
||||||
let g:testvar ..= '(' .. a:mods .. ')'
|
if a:mods !=# ' '
|
||||||
endif
|
let g:testvar ..= '(' .. a:mods .. ')'
|
||||||
endfunction
|
endif
|
||||||
set stc=%0@MyClickFunc@%=%l%T
|
endfunction
|
||||||
]])
|
set stc=%0@MyClickFunc@%=%l%T
|
||||||
meths.input_mouse('left', 'press', '', 0, 0, 0)
|
]])
|
||||||
eq('0 1 l 4', eval("g:testvar"))
|
meths.input_mouse('left', 'press', '', 0, 0, 0)
|
||||||
meths.input_mouse('left', 'press', '', 0, 0, 0)
|
eq('0 1 l 4', eval("g:testvar"))
|
||||||
eq('0 2 l 4', eval("g:testvar"))
|
meths.input_mouse('left', 'press', '', 0, 0, 0)
|
||||||
meths.input_mouse('left', 'press', '', 0, 0, 0)
|
eq('0 2 l 4', eval("g:testvar"))
|
||||||
eq('0 3 l 4', eval("g:testvar"))
|
meths.input_mouse('left', 'press', '', 0, 0, 0)
|
||||||
meths.input_mouse('left', 'press', '', 0, 0, 0)
|
eq('0 3 l 4', eval("g:testvar"))
|
||||||
eq('0 4 l 4', eval("g:testvar"))
|
meths.input_mouse('left', 'press', '', 0, 0, 0)
|
||||||
meths.input_mouse('right', 'press', '', 0, 3, 0)
|
eq('0 4 l 4', eval("g:testvar"))
|
||||||
eq('0 1 r 7', eval("g:testvar"))
|
meths.input_mouse('right', 'press', '', 0, 3, 0)
|
||||||
meths.input_mouse('right', 'press', '', 0, 3, 0)
|
eq('0 1 r 7', eval("g:testvar"))
|
||||||
eq('0 2 r 7', eval("g:testvar"))
|
meths.input_mouse('right', 'press', '', 0, 3, 0)
|
||||||
meths.input_mouse('right', 'press', '', 0, 3, 0)
|
eq('0 2 r 7', eval("g:testvar"))
|
||||||
eq('0 3 r 7', eval("g:testvar"))
|
meths.input_mouse('right', 'press', '', 0, 3, 0)
|
||||||
meths.input_mouse('right', 'press', '', 0, 3, 0)
|
eq('0 3 r 7', eval("g:testvar"))
|
||||||
eq('0 4 r 7', eval("g:testvar"))
|
meths.input_mouse('right', 'press', '', 0, 3, 0)
|
||||||
command('set laststatus=2 winbar=%f')
|
eq('0 4 r 7', eval("g:testvar"))
|
||||||
command('let g:testvar=""')
|
command('set laststatus=2 winbar=%f')
|
||||||
-- Check that winbar click doesn't register as statuscolumn click
|
command('let g:testvar=""')
|
||||||
meths.input_mouse('right', 'press', '', 0, 0, 0)
|
-- Check that winbar click doesn't register as statuscolumn click
|
||||||
eq('', eval("g:testvar"))
|
meths.input_mouse('right', 'press', '', 0, 0, 0)
|
||||||
-- Check that statusline click doesn't register as statuscolumn click
|
eq('', eval("g:testvar"))
|
||||||
meths.input_mouse('right', 'press', '', 0, 12, 0)
|
-- Check that statusline click doesn't register as statuscolumn click
|
||||||
eq('', eval("g:testvar"))
|
meths.input_mouse('right', 'press', '', 0, 12, 0)
|
||||||
-- Check that cmdline click doesn't register as statuscolumn click
|
eq('', eval("g:testvar"))
|
||||||
meths.input_mouse('right', 'press', '', 0, 13, 0)
|
-- Check that cmdline click doesn't register as statuscolumn click
|
||||||
eq('', eval("g:testvar"))
|
meths.input_mouse('right', 'press', '', 0, 13, 0)
|
||||||
end)
|
eq('', eval("g:testvar"))
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
it('click labels do not leak memory', function()
|
it('click labels do not leak memory', function()
|
||||||
command([[
|
command([[
|
||||||
|
@@ -12,178 +12,182 @@ local exec_lua = helpers.exec_lua
|
|||||||
local eval = helpers.eval
|
local eval = helpers.eval
|
||||||
local sleep = helpers.sleep
|
local sleep = helpers.sleep
|
||||||
|
|
||||||
describe('statusline clicks', function()
|
local mousemodels = { "extend", "popup", "popup_setpos" }
|
||||||
local screen
|
|
||||||
|
|
||||||
before_each(function()
|
for _, model in ipairs(mousemodels) do
|
||||||
clear()
|
describe('statusline clicks with mousemodel=' .. model, function()
|
||||||
screen = Screen.new(40, 8)
|
local screen
|
||||||
screen:attach()
|
|
||||||
command('set laststatus=2 mousemodel=extend')
|
|
||||||
exec([=[
|
|
||||||
function! MyClickFunc(minwid, clicks, button, mods)
|
|
||||||
let g:testvar = printf("%d %d %s", a:minwid, a:clicks, a:button)
|
|
||||||
if a:mods !=# ' '
|
|
||||||
let g:testvar ..= '(' .. a:mods .. ')'
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
]=])
|
|
||||||
end)
|
|
||||||
|
|
||||||
it('works', function()
|
before_each(function()
|
||||||
meths.set_option('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T')
|
clear()
|
||||||
meths.input_mouse('left', 'press', '', 0, 6, 17)
|
screen = Screen.new(40, 8)
|
||||||
eq('0 1 l', eval("g:testvar"))
|
screen:attach()
|
||||||
meths.input_mouse('left', 'press', '', 0, 6, 17)
|
command('set laststatus=2 mousemodel=' .. model)
|
||||||
eq('0 2 l', eval("g:testvar"))
|
exec([=[
|
||||||
meths.input_mouse('left', 'press', '', 0, 6, 17)
|
function! MyClickFunc(minwid, clicks, button, mods)
|
||||||
eq('0 3 l', eval("g:testvar"))
|
let g:testvar = printf("%d %d %s", a:minwid, a:clicks, a:button)
|
||||||
meths.input_mouse('left', 'press', '', 0, 6, 17)
|
if a:mods !=# ' '
|
||||||
eq('0 4 l', eval("g:testvar"))
|
let g:testvar ..= '(' .. a:mods .. ')'
|
||||||
meths.input_mouse('right', 'press', '', 0, 6, 17)
|
endif
|
||||||
eq('0 1 r', eval("g:testvar"))
|
endfunction
|
||||||
meths.input_mouse('right', 'press', '', 0, 6, 17)
|
]=])
|
||||||
eq('0 2 r', eval("g:testvar"))
|
end)
|
||||||
meths.input_mouse('right', 'press', '', 0, 6, 17)
|
|
||||||
eq('0 3 r', eval("g:testvar"))
|
|
||||||
meths.input_mouse('right', 'press', '', 0, 6, 17)
|
|
||||||
eq('0 4 r', eval("g:testvar"))
|
|
||||||
end)
|
|
||||||
|
|
||||||
it('works for winbar', function()
|
it('works', function()
|
||||||
meths.set_option('winbar', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T')
|
meths.set_option('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T')
|
||||||
meths.input_mouse('left', 'press', '', 0, 0, 17)
|
meths.input_mouse('left', 'press', '', 0, 6, 17)
|
||||||
eq('0 1 l', eval("g:testvar"))
|
eq('0 1 l', eval("g:testvar"))
|
||||||
meths.input_mouse('right', 'press', '', 0, 0, 17)
|
meths.input_mouse('left', 'press', '', 0, 6, 17)
|
||||||
eq('0 1 r', eval("g:testvar"))
|
eq('0 2 l', eval("g:testvar"))
|
||||||
end)
|
meths.input_mouse('left', 'press', '', 0, 6, 17)
|
||||||
|
eq('0 3 l', eval("g:testvar"))
|
||||||
|
meths.input_mouse('left', 'press', '', 0, 6, 17)
|
||||||
|
eq('0 4 l', eval("g:testvar"))
|
||||||
|
meths.input_mouse('right', 'press', '', 0, 6, 17)
|
||||||
|
eq('0 1 r', eval("g:testvar"))
|
||||||
|
meths.input_mouse('right', 'press', '', 0, 6, 17)
|
||||||
|
eq('0 2 r', eval("g:testvar"))
|
||||||
|
meths.input_mouse('right', 'press', '', 0, 6, 17)
|
||||||
|
eq('0 3 r', eval("g:testvar"))
|
||||||
|
meths.input_mouse('right', 'press', '', 0, 6, 17)
|
||||||
|
eq('0 4 r', eval("g:testvar"))
|
||||||
|
end)
|
||||||
|
|
||||||
it('works for winbar in floating window', function()
|
it('works for winbar', function()
|
||||||
meths.open_win(0, true, { width=30, height=4, relative='editor', row=1, col=5,
|
meths.set_option('winbar', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T')
|
||||||
border = "single" })
|
meths.input_mouse('left', 'press', '', 0, 0, 17)
|
||||||
meths.set_option_value('winbar', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T',
|
eq('0 1 l', eval("g:testvar"))
|
||||||
{ scope = 'local' })
|
meths.input_mouse('right', 'press', '', 0, 0, 17)
|
||||||
meths.input_mouse('left', 'press', '', 0, 2, 23)
|
eq('0 1 r', eval("g:testvar"))
|
||||||
eq('0 1 l', eval("g:testvar"))
|
end)
|
||||||
end)
|
|
||||||
|
|
||||||
it('works when there are multiple windows', function()
|
it('works for winbar in floating window', function()
|
||||||
command('split')
|
meths.open_win(0, true, { width=30, height=4, relative='editor', row=1, col=5,
|
||||||
meths.set_option('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T')
|
border = "single" })
|
||||||
meths.set_option('winbar', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T')
|
meths.set_option_value('winbar', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T',
|
||||||
meths.input_mouse('left', 'press', '', 0, 0, 17)
|
{ scope = 'local' })
|
||||||
eq('0 1 l', eval("g:testvar"))
|
meths.input_mouse('left', 'press', '', 0, 2, 23)
|
||||||
meths.input_mouse('right', 'press', '', 0, 4, 17)
|
eq('0 1 l', eval("g:testvar"))
|
||||||
eq('0 1 r', eval("g:testvar"))
|
end)
|
||||||
meths.input_mouse('middle', 'press', '', 0, 3, 17)
|
|
||||||
eq('0 1 m', eval("g:testvar"))
|
|
||||||
meths.input_mouse('left', 'press', '', 0, 6, 17)
|
|
||||||
eq('0 1 l', eval("g:testvar"))
|
|
||||||
end)
|
|
||||||
|
|
||||||
it('works with Lua function', function()
|
it('works when there are multiple windows', function()
|
||||||
exec_lua([[
|
command('split')
|
||||||
function clicky_func(minwid, clicks, button, mods)
|
meths.set_option('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T')
|
||||||
vim.g.testvar = string.format("%d %d %s", minwid, clicks, button)
|
meths.set_option('winbar', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T')
|
||||||
end
|
meths.input_mouse('left', 'press', '', 0, 0, 17)
|
||||||
]])
|
eq('0 1 l', eval("g:testvar"))
|
||||||
meths.set_option('statusline', 'Not clicky stuff %0@v:lua.clicky_func@Clicky stuff%T')
|
meths.input_mouse('right', 'press', '', 0, 4, 17)
|
||||||
meths.input_mouse('left', 'press', '', 0, 6, 17)
|
eq('0 1 r', eval("g:testvar"))
|
||||||
eq('0 1 l', eval("g:testvar"))
|
meths.input_mouse('middle', 'press', '', 0, 3, 17)
|
||||||
end)
|
eq('0 1 m', eval("g:testvar"))
|
||||||
|
meths.input_mouse('left', 'press', '', 0, 6, 17)
|
||||||
|
eq('0 1 l', eval("g:testvar"))
|
||||||
|
end)
|
||||||
|
|
||||||
it('ignores unsupported click items', function()
|
it('works with Lua function', function()
|
||||||
command('tabnew | tabprevious')
|
exec_lua([[
|
||||||
meths.set_option('statusline', '%2TNot clicky stuff%T')
|
function clicky_func(minwid, clicks, button, mods)
|
||||||
meths.input_mouse('left', 'press', '', 0, 6, 0)
|
vim.g.testvar = string.format("%d %d %s", minwid, clicks, button)
|
||||||
eq(1, meths.get_current_tabpage().id)
|
end
|
||||||
meths.set_option('statusline', '%2XNot clicky stuff%X')
|
]])
|
||||||
meths.input_mouse('left', 'press', '', 0, 6, 0)
|
meths.set_option('statusline', 'Not clicky stuff %0@v:lua.clicky_func@Clicky stuff%T')
|
||||||
eq(2, #meths.list_tabpages())
|
meths.input_mouse('left', 'press', '', 0, 6, 17)
|
||||||
end)
|
eq('0 1 l', eval("g:testvar"))
|
||||||
|
end)
|
||||||
|
|
||||||
it("right click works when statusline isn't focused #18994", function()
|
it('ignores unsupported click items', function()
|
||||||
meths.set_option('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T')
|
command('tabnew | tabprevious')
|
||||||
meths.input_mouse('right', 'press', '', 0, 6, 17)
|
meths.set_option('statusline', '%2TNot clicky stuff%T')
|
||||||
eq('0 1 r', eval("g:testvar"))
|
meths.input_mouse('left', 'press', '', 0, 6, 0)
|
||||||
meths.input_mouse('right', 'press', '', 0, 6, 17)
|
eq(1, meths.get_current_tabpage().id)
|
||||||
eq('0 2 r', eval("g:testvar"))
|
meths.set_option('statusline', '%2XNot clicky stuff%X')
|
||||||
end)
|
meths.input_mouse('left', 'press', '', 0, 6, 0)
|
||||||
|
eq(2, #meths.list_tabpages())
|
||||||
|
end)
|
||||||
|
|
||||||
it("works with modifiers #18994", function()
|
it("right click works when statusline isn't focused #18994", function()
|
||||||
meths.set_option('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T')
|
meths.set_option('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T')
|
||||||
-- Note: alternate between left and right mouse buttons to avoid triggering multiclicks
|
meths.input_mouse('right', 'press', '', 0, 6, 17)
|
||||||
meths.input_mouse('left', 'press', 'S', 0, 6, 17)
|
eq('0 1 r', eval("g:testvar"))
|
||||||
eq('0 1 l(s )', eval("g:testvar"))
|
meths.input_mouse('right', 'press', '', 0, 6, 17)
|
||||||
meths.input_mouse('right', 'press', 'S', 0, 6, 17)
|
eq('0 2 r', eval("g:testvar"))
|
||||||
eq('0 1 r(s )', eval("g:testvar"))
|
end)
|
||||||
meths.input_mouse('left', 'press', 'A', 0, 6, 17)
|
|
||||||
eq('0 1 l( a )', eval("g:testvar"))
|
|
||||||
meths.input_mouse('right', 'press', 'A', 0, 6, 17)
|
|
||||||
eq('0 1 r( a )', eval("g:testvar"))
|
|
||||||
meths.input_mouse('left', 'press', 'AS', 0, 6, 17)
|
|
||||||
eq('0 1 l(s a )', eval("g:testvar"))
|
|
||||||
meths.input_mouse('right', 'press', 'AS', 0, 6, 17)
|
|
||||||
eq('0 1 r(s a )', eval("g:testvar"))
|
|
||||||
meths.input_mouse('left', 'press', 'T', 0, 6, 17)
|
|
||||||
eq('0 1 l( m)', eval("g:testvar"))
|
|
||||||
meths.input_mouse('right', 'press', 'T', 0, 6, 17)
|
|
||||||
eq('0 1 r( m)', eval("g:testvar"))
|
|
||||||
meths.input_mouse('left', 'press', 'TS', 0, 6, 17)
|
|
||||||
eq('0 1 l(s m)', eval("g:testvar"))
|
|
||||||
meths.input_mouse('right', 'press', 'TS', 0, 6, 17)
|
|
||||||
eq('0 1 r(s m)', eval("g:testvar"))
|
|
||||||
meths.input_mouse('left', 'press', 'C', 0, 6, 17)
|
|
||||||
eq('0 1 l( c )', eval("g:testvar"))
|
|
||||||
-- <C-RightMouse> is for tag jump
|
|
||||||
end)
|
|
||||||
|
|
||||||
it("works for global statusline with vertical splits #19186", function()
|
it("works with modifiers #18994", function()
|
||||||
command('set laststatus=3')
|
meths.set_option('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T')
|
||||||
meths.set_option('statusline', '%0@MyClickFunc@Clicky stuff%T %= %0@MyClickFunc@Clicky stuff%T')
|
-- Note: alternate between left and right mouse buttons to avoid triggering multiclicks
|
||||||
command('vsplit')
|
meths.input_mouse('left', 'press', 'S', 0, 6, 17)
|
||||||
screen:expect([[
|
eq('0 1 l(s )', eval("g:testvar"))
|
||||||
^ │ |
|
meths.input_mouse('right', 'press', 'S', 0, 6, 17)
|
||||||
~ │~ |
|
eq('0 1 r(s )', eval("g:testvar"))
|
||||||
~ │~ |
|
meths.input_mouse('left', 'press', 'A', 0, 6, 17)
|
||||||
~ │~ |
|
eq('0 1 l( a )', eval("g:testvar"))
|
||||||
~ │~ |
|
meths.input_mouse('right', 'press', 'A', 0, 6, 17)
|
||||||
~ │~ |
|
eq('0 1 r( a )', eval("g:testvar"))
|
||||||
Clicky stuff Clicky stuff|
|
meths.input_mouse('left', 'press', 'AS', 0, 6, 17)
|
||||||
|
|
eq('0 1 l(s a )', eval("g:testvar"))
|
||||||
]])
|
meths.input_mouse('right', 'press', 'AS', 0, 6, 17)
|
||||||
|
eq('0 1 r(s a )', eval("g:testvar"))
|
||||||
|
meths.input_mouse('left', 'press', 'T', 0, 6, 17)
|
||||||
|
eq('0 1 l( m)', eval("g:testvar"))
|
||||||
|
meths.input_mouse('right', 'press', 'T', 0, 6, 17)
|
||||||
|
eq('0 1 r( m)', eval("g:testvar"))
|
||||||
|
meths.input_mouse('left', 'press', 'TS', 0, 6, 17)
|
||||||
|
eq('0 1 l(s m)', eval("g:testvar"))
|
||||||
|
meths.input_mouse('right', 'press', 'TS', 0, 6, 17)
|
||||||
|
eq('0 1 r(s m)', eval("g:testvar"))
|
||||||
|
meths.input_mouse('left', 'press', 'C', 0, 6, 17)
|
||||||
|
eq('0 1 l( c )', eval("g:testvar"))
|
||||||
|
-- <C-RightMouse> is for tag jump
|
||||||
|
end)
|
||||||
|
|
||||||
-- clickable area on the right
|
it("works for global statusline with vertical splits #19186", function()
|
||||||
meths.input_mouse('left', 'press', '', 0, 6, 35)
|
command('set laststatus=3')
|
||||||
eq('0 1 l', eval("g:testvar"))
|
meths.set_option('statusline', '%0@MyClickFunc@Clicky stuff%T %= %0@MyClickFunc@Clicky stuff%T')
|
||||||
meths.input_mouse('right', 'press', '', 0, 6, 35)
|
command('vsplit')
|
||||||
eq('0 1 r', eval("g:testvar"))
|
screen:expect([[
|
||||||
|
^ │ |
|
||||||
|
~ │~ |
|
||||||
|
~ │~ |
|
||||||
|
~ │~ |
|
||||||
|
~ │~ |
|
||||||
|
~ │~ |
|
||||||
|
Clicky stuff Clicky stuff|
|
||||||
|
|
|
||||||
|
]])
|
||||||
|
|
||||||
-- clickable area on the left
|
-- clickable area on the right
|
||||||
meths.input_mouse('left', 'press', '', 0, 6, 5)
|
meths.input_mouse('left', 'press', '', 0, 6, 35)
|
||||||
eq('0 1 l', eval("g:testvar"))
|
eq('0 1 l', eval("g:testvar"))
|
||||||
meths.input_mouse('right', 'press', '', 0, 6, 5)
|
meths.input_mouse('right', 'press', '', 0, 6, 35)
|
||||||
eq('0 1 r', eval("g:testvar"))
|
eq('0 1 r', eval("g:testvar"))
|
||||||
end)
|
|
||||||
|
|
||||||
it('no memory leak with zero-width click labels', function()
|
-- clickable area on the left
|
||||||
command([[
|
meths.input_mouse('left', 'press', '', 0, 6, 5)
|
||||||
let &stl = '%@Test@%T%@MyClickFunc@%=%T%@Test@'
|
eq('0 1 l', eval("g:testvar"))
|
||||||
]])
|
meths.input_mouse('right', 'press', '', 0, 6, 5)
|
||||||
meths.input_mouse('left', 'press', '', 0, 6, 0)
|
eq('0 1 r', eval("g:testvar"))
|
||||||
eq('0 1 l', eval("g:testvar"))
|
end)
|
||||||
meths.input_mouse('right', 'press', '', 0, 6, 39)
|
|
||||||
eq('0 1 r', eval("g:testvar"))
|
|
||||||
end)
|
|
||||||
|
|
||||||
it('no memory leak with truncated click labels', function()
|
it('no memory leak with zero-width click labels', function()
|
||||||
command([[
|
command([[
|
||||||
let &stl = '%@MyClickFunc@foo%X' .. repeat('a', 40) .. '%<t%@Test@bar%X%@Test@baz'
|
let &stl = '%@Test@%T%@MyClickFunc@%=%T%@Test@'
|
||||||
]])
|
]])
|
||||||
meths.input_mouse('left', 'press', '', 0, 6, 2)
|
meths.input_mouse('left', 'press', '', 0, 6, 0)
|
||||||
eq('0 1 l', eval("g:testvar"))
|
eq('0 1 l', eval("g:testvar"))
|
||||||
end)
|
meths.input_mouse('right', 'press', '', 0, 6, 39)
|
||||||
end)
|
eq('0 1 r', eval("g:testvar"))
|
||||||
|
end)
|
||||||
|
|
||||||
|
it('no memory leak with truncated click labels', function()
|
||||||
|
command([[
|
||||||
|
let &stl = '%@MyClickFunc@foo%X' .. repeat('a', 40) .. '%<t%@Test@bar%X%@Test@baz'
|
||||||
|
]])
|
||||||
|
meths.input_mouse('left', 'press', '', 0, 6, 2)
|
||||||
|
eq('0 1 l', eval("g:testvar"))
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
describe('global statusline', function()
|
describe('global statusline', function()
|
||||||
local screen
|
local screen
|
||||||
|
Reference in New Issue
Block a user