diff options
| author | zeertzjq <zeertzjq@outlook.com> | 2026-04-09 12:11:32 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-04-09 04:11:32 +0000 |
| commit | 9c5fba5df0b60cd25ac2c180a7d82fca47a105e6 (patch) | |
| tree | 60e64ae61d5a2b09313c0bfe88889340ff452939 /runtime/lua/vim | |
| parent | 3a4a66017b74192caaf9af9af172bdc08e0c1608 (diff) | |
| download | rneovim-9c5fba5df0b60cd25ac2c180a7d82fca47a105e6.tar.gz rneovim-9c5fba5df0b60cd25ac2c180a7d82fca47a105e6.tar.bz2 rneovim-9c5fba5df0b60cd25ac2c180a7d82fca47a105e6.zip | |
fix(messages): truncate warning messages only in display (#38901)
For now, add a private "_truncate" flag to nvim_echo, using a truncation
method similar to showmode().
Diffstat (limited to 'runtime/lua/vim')
| -rw-r--r-- | runtime/lua/vim/_core/defaults.lua | 6 | ||||
| -rw-r--r-- | runtime/lua/vim/_core/editor.lua | 10 | ||||
| -rw-r--r-- | runtime/lua/vim/_meta/api_keysets.lua | 1 |
3 files changed, 11 insertions, 6 deletions
diff --git a/runtime/lua/vim/_core/defaults.lua b/runtime/lua/vim/_core/defaults.lua index 2b9eab922c..1a2b7e6a6b 100644 --- a/runtime/lua/vim/_core/defaults.lua +++ b/runtime/lua/vim/_core/defaults.lua @@ -780,7 +780,8 @@ do vim.v.swapchoice = 'e' -- Choose "(E)dit". vim.notify( ('W325: Ignoring swapfile from Nvim process %d'):format(info.pid), - vim.log.levels.WARN + vim.log.levels.WARN, + { _truncate = true } ) end, }) @@ -991,7 +992,8 @@ do then vim.notify( 'defaults.lua: Did not detect DSR response from terminal. This results in a slower startup time.', - vim.log.levels.WARN + vim.log.levels.WARN, + { _truncate = true } ) end end diff --git a/runtime/lua/vim/_core/editor.lua b/runtime/lua/vim/_core/editor.lua index bfc5e318fc..0881ea0ff5 100644 --- a/runtime/lua/vim/_core/editor.lua +++ b/runtime/lua/vim/_core/editor.lua @@ -547,7 +547,11 @@ end ---@diagnostic disable-next-line: unused-local function vim.notify(msg, level, opts) -- luacheck: no unused args local chunks = { { msg, level == vim.log.levels.WARN and 'WarningMsg' or nil } } - vim.api.nvim_echo(chunks, true, { err = level == vim.log.levels.ERROR }) + vim.api.nvim_echo( + chunks, + true, + { err = level == vim.log.levels.ERROR, _truncate = opts and opts._truncate } + ) end do @@ -1213,9 +1217,7 @@ end do local function truncated_echo(msg) -- Truncate message to avoid hit-enter-prompt - local max_width = vim.o.columns * math.max(vim.o.cmdheight - 1, 0) + vim.v.echospace - local msg_truncated = string.sub(msg, 1, max_width) - vim.api.nvim_echo({ { msg_truncated, 'WarningMsg' } }, true, {}) + vim.api.nvim_echo({ { msg, 'WarningMsg' } }, true, { _truncate = true }) end local notified = false diff --git a/runtime/lua/vim/_meta/api_keysets.lua b/runtime/lua/vim/_meta/api_keysets.lua index 68f433f062..33bfde5fea 100644 --- a/runtime/lua/vim/_meta/api_keysets.lua +++ b/runtime/lua/vim/_meta/api_keysets.lua @@ -239,6 +239,7 @@ error('Cannot require a meta file') --- @class vim.api.keyset.echo_opts --- @field err? boolean --- @field verbose? boolean +--- @field _truncate? boolean --- @field kind? string --- @field id? integer|string --- @field title? string |