From 9c5fba5df0b60cd25ac2c180a7d82fca47a105e6 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 9 Apr 2026 12:11:32 +0800 Subject: 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(). --- test/functional/lua/vim_spec.lua | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) (limited to 'test/functional/lua/vim_spec.lua') diff --git a/test/functional/lua/vim_spec.lua b/test/functional/lua/vim_spec.lua index e80fb777f3..7ab615afa7 100644 --- a/test/functional/lua/vim_spec.lua +++ b/test/functional/lua/vim_spec.lua @@ -134,18 +134,20 @@ describe('lua stdlib', function() describe(('vim.deprecate prerel=%s,'):format(prerel or 'nil'), function() local curver --- @type {major:number, minor:number} + local curstr --- @type string + local nextver --- @type string before_each(function() curver = exec_lua('return vim.version()') + -- "0.10" or "0.10-dev+xxx" + curstr = ('%s.%s%s'):format(curver.major, curver.minor, prerel or '') + -- "0.10" or "0.11" + nextver = ('%s.%s'):format(curver.major, curver.minor + (prerel and 0 or 1)) end) it('plugin=nil, same message skipped', function() - -- "0.10" or "0.10-dev+xxx" - local curstr = ('%s.%s%s'):format(curver.major, curver.minor, prerel or '') eq( - ([[foo.bar() is deprecated. Run ":checkhealth vim.deprecated" for more information]]):format( - curstr - ), + [[foo.bar() is deprecated. Run ":checkhealth vim.deprecated" for more information]], exec_lua('return vim.deprecate(...)', 'foo.bar()', 'zub.wooo{ok=yay}', curstr) ) -- Same message as above; skipped this time. @@ -160,19 +162,26 @@ describe('lua stdlib', function() end) it('plugin=nil, show error if hard-deprecated', function() - -- "0.10" or "0.11" - local nextver = ('%s.%s'):format(curver.major, curver.minor + (prerel and 0 or 1)) - - local was_removed = prerel and 'was removed' or 'will be removed' eq( - dedent( - [[ - foo.hard_dep() is deprecated. Run ":checkhealth vim.deprecated" for more information]] - ):format(was_removed, nextver), + [[foo.hard_dep() is deprecated. Run ":checkhealth vim.deprecated" for more information]], exec_lua('return vim.deprecate(...)', 'foo.hard_dep()', 'vim.new_api()', nextver) ) end) + it('plugin=nil, message is only truncated in display #38841', function() + local screen = Screen.new(50, 10) + exec_lua('vim.deprecate(...)', 'foo.bar()', 'zub.wooo{ok=yay}', curstr) + screen:expect([[ + ^ | + {1:~ }|*8 + {19:foo.bar() is deprecated. Run ":checkhealth vim.dep}| + ]]) + eq( + [[foo.bar() is deprecated. Run ":checkhealth vim.deprecated" for more information]], + n.exec_capture('messages') + ) + end) + it('plugin specified', function() -- When `plugin` is specified, don't show ":help deprecated". #22235 eq( -- cgit