summaryrefslogtreecommitdiffstatshomepage
path: root/runtime/lua/vim/_core/ui2.lua
diff options
context:
space:
mode:
authorluukvbaal <luukvbaal@gmail.com>2026-02-24 23:05:38 +0100
committerGitHub <noreply@github.com>2026-02-24 17:05:38 -0500
commit844caca881f85fa4e143fbfa982fba48590e8a60 (patch)
tree2448809399e0124fac78c41c3a2c0fe0b7099a82 /runtime/lua/vim/_core/ui2.lua
parent16aab4cb48e19c8236eda788c50b6b475ebfa1b0 (diff)
fix(ui2): multiline/color replaced message, expanded cmdline, error messages #38044
Problem: - Unintentionally inserting lines for a replaced multiline message that also has multiple highlights. - Scheduled check to see if the expanded cmdline window was entered makes it difficult to keep track of what happens when the key pressed to dismiss it results in a message. - Reading the first line of an error message should be enough notice for something going wrong. - "search_cmd" messages should not be shown with 0 'cmdheight'. - Unable to configure dynamically changed pager height. - Enabling UI2 doesn't make sense with no UIs attached. Solution: - Only insert a line for the first chunk after a newline. - Use getmousepos() to check if the expanded cmdline was clicked to enter the pager. entering the pager to serve as a configuration interface. - Don't expand the cmdline for error messages; user can press g<. - Don't show "search_cmd" messages with 'cmdheight' set to 0. - Change 'eventignorewin' to ensure WinEnter is fired when - Have enable() return early when no UIs are attached.
Diffstat (limited to 'runtime/lua/vim/_core/ui2.lua')
-rw-r--r--runtime/lua/vim/_core/ui2.lua12
1 files changed, 7 insertions, 5 deletions
diff --git a/runtime/lua/vim/_core/ui2.lua b/runtime/lua/vim/_core/ui2.lua
index 33c8c6ae0f..4e1d9a3534 100644
--- a/runtime/lua/vim/_core/ui2.lua
+++ b/runtime/lua/vim/_core/ui2.lua
@@ -59,6 +59,7 @@ local wincfg = { -- Default cfg for nvim_open_win().
width = 10000,
height = 1,
noautocmd = true,
+ focusable = false,
}
local tab = 0
@@ -77,7 +78,6 @@ function M.check_targets()
or not api.nvim_win_get_config(M.wins[type]).zindex -- no longer floating
then
local cfg = vim.tbl_deep_extend('force', wincfg, {
- focusable = type == 'pager',
mouse = type ~= 'cmd' and true or nil,
anchor = type ~= 'cmd' and 'SE' or nil,
hide = type ~= 'cmd' or M.cmdheight == 0 or nil,
@@ -100,8 +100,7 @@ function M.check_targets()
if setopt then
-- Set options without firing OptionSet and BufFilePost.
vim._with({ win = M.wins[type], noautocmd = true }, function()
- local ignore = 'all,-FileType' .. (type == 'pager' and ',-TextYankPost' or '')
- api.nvim_set_option_value('eventignorewin', ignore, { scope = 'local' })
+ api.nvim_set_option_value('eventignorewin', 'all,-FileType', { scope = 'local' })
api.nvim_set_option_value('wrap', true, { scope = 'local' })
api.nvim_set_option_value('linebreak', false, { scope = 'local' })
api.nvim_set_option_value('smoothscroll', true, { scope = 'local' })
@@ -161,8 +160,9 @@ local scheduled_ui_callback = vim.schedule_wrap(ui_callback)
function M.enable(opts)
vim.validate('opts', opts, 'table', true)
M.cfg = vim.tbl_deep_extend('keep', opts, M.cfg)
- M.cmd = require('vim._core.ui2.cmdline')
- M.msg = require('vim._core.ui2.messages')
+ if #vim.api.nvim_list_uis() == 0 then
+ return -- Don't prevent stdout messaging when no UIs are attached.
+ end
if M.cfg.enable == false then
-- Detach and cleanup windows, buffers and autocommands.
@@ -181,6 +181,8 @@ function M.enable(opts)
return
end
+ M.cmd = require('vim._core.ui2.cmdline')
+ M.msg = require('vim._core.ui2.messages')
vim.ui_attach(M.ns, { ext_messages = true, set_cmdheight = false }, function(event, ...)
if not (M.msg[event] or M.cmd[event]) then
return