mirror of
https://github.com/neovim/neovim.git
synced 2024-09-17 20:58:20 -04:00
feat(ui): disregard floats with focusable set to false
Floats with focusable set to false can be reasonably expected to be UI elements. Showing them in certain places could be considered unexpected, especially considering the plan of moving message grid to floating windows. This handles the default tabline and :tabs, there might be others.
This commit is contained in:
parent
cff8c15977
commit
e2ef77c883
@ -3199,7 +3199,8 @@ nvim_open_win({buffer}, {enter}, {config}) *nvim_open_win()*
|
||||
be fractional.
|
||||
• focusable: Enable focus by user actions (wincmds, mouse
|
||||
events). Defaults to true. Non-focusable windows can be
|
||||
entered by |nvim_set_current_win()|.
|
||||
entered by |nvim_set_current_win()|, and are considered UI
|
||||
elements; Nvim may treat them as such.
|
||||
• external: GUI should display the window as an external
|
||||
top-level window. Currently accepts no other positioning
|
||||
configuration together with this.
|
||||
|
3
runtime/lua/vim/_meta/api.lua
generated
3
runtime/lua/vim/_meta/api.lua
generated
@ -1636,7 +1636,8 @@ function vim.api.nvim_open_term(buffer, opts) end
|
||||
--- be fractional.
|
||||
--- • focusable: Enable focus by user actions (wincmds, mouse
|
||||
--- events). Defaults to true. Non-focusable windows can be
|
||||
--- entered by `nvim_set_current_win()`.
|
||||
--- entered by `nvim_set_current_win()`, and are considered UI
|
||||
--- elements; Nvim may treat them as such.
|
||||
--- • external: GUI should display the window as an external
|
||||
--- top-level window. Currently accepts no other positioning
|
||||
--- configuration together with this.
|
||||
|
@ -128,7 +128,8 @@
|
||||
/// fractional.
|
||||
/// - focusable: Enable focus by user actions (wincmds, mouse events).
|
||||
/// Defaults to true. Non-focusable windows can be entered by
|
||||
/// |nvim_set_current_win()|.
|
||||
/// |nvim_set_current_win()|, and are considered UI elements;
|
||||
/// Nvim may treat them as such.
|
||||
/// - external: GUI should display the window as an external
|
||||
/// top-level window. Currently accepts no other positioning
|
||||
/// configuration together with this.
|
||||
|
@ -5307,6 +5307,8 @@ static void ex_tabs(exarg_T *eap)
|
||||
FOR_ALL_WINDOWS_IN_TAB(wp, tp) {
|
||||
if (got_int) {
|
||||
break;
|
||||
} else if (!wp->w_config.focusable) {
|
||||
continue;
|
||||
}
|
||||
|
||||
msg_putchar('\n');
|
||||
|
@ -777,7 +777,9 @@ void draw_tabline(void)
|
||||
bool modified = false;
|
||||
|
||||
for (wincount = 0; wp != NULL; wp = wp->w_next, wincount++) {
|
||||
if (bufIsChanged(wp->w_buffer)) {
|
||||
if (!wp->w_config.focusable) {
|
||||
wincount--;
|
||||
} else if (bufIsChanged(wp->w_buffer)) {
|
||||
modified = true;
|
||||
}
|
||||
}
|
||||
|
@ -194,4 +194,43 @@ describe('tabline', function()
|
||||
api.nvim_input_mouse('middle', 'press', '', 0, 0, 1)
|
||||
eq({ 1, 1 }, api.nvim_eval('[tabpagenr(), tabpagenr("$")]'))
|
||||
end)
|
||||
|
||||
it('does not show floats with focusable=false', function()
|
||||
screen:set_default_attr_ids({
|
||||
[1] = { background = Screen.colors.Plum1 },
|
||||
[2] = { underline = true, background = Screen.colors.LightGrey },
|
||||
[3] = { bold = true },
|
||||
[4] = { reverse = true },
|
||||
[5] = { bold = true, foreground = Screen.colors.Blue1 },
|
||||
[6] = { foreground = Screen.colors.Fuchsia, bold = true },
|
||||
[7] = { foreground = Screen.colors.SeaGreen, bold = true },
|
||||
})
|
||||
command('tabnew')
|
||||
api.nvim_open_win(0, false, {
|
||||
focusable = false,
|
||||
relative = 'editor',
|
||||
height = 1,
|
||||
width = 1,
|
||||
row = 0,
|
||||
col = 0,
|
||||
})
|
||||
screen:expect {
|
||||
grid = [[
|
||||
{1: }{2:[No Name] }{3: [No Name] }{4: }{2:X}|
|
||||
^ |
|
||||
{5:~ }|*2
|
||||
|
|
||||
]],
|
||||
}
|
||||
command('tabs')
|
||||
screen:expect {
|
||||
grid = [[
|
||||
{6:Tab page 1} |
|
||||
# [No Name] |
|
||||
{6:Tab page 2} |
|
||||
> [No Name] |
|
||||
{7:Press ENTER or type command to continue}^ |
|
||||
]],
|
||||
}
|
||||
end)
|
||||
end)
|
||||
|
Loading…
Reference in New Issue
Block a user