aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-08-15 22:02:20 +0800
committerGitHub <noreply@github.com>2024-08-15 22:02:20 +0800
commitee5aaba21560c3836f46d347c216832864f85668 (patch)
tree70aedaed9770fcba721933ced1f77ed1a3d91d2a
parent4199671047b0cb62781995a8f6a4b66fb6e8b6fd (diff)
downloadrneovim-ee5aaba21560c3836f46d347c216832864f85668.tar.gz
rneovim-ee5aaba21560c3836f46d347c216832864f85668.tar.bz2
rneovim-ee5aaba21560c3836f46d347c216832864f85668.zip
fix(man): avoid setting v:errmsg (#30052)
-rw-r--r--runtime/lua/man.lua8
-rw-r--r--test/functional/plugin/man_spec.lua2
2 files changed, 8 insertions, 2 deletions
diff --git a/runtime/lua/man.lua b/runtime/lua/man.lua
index 348e502f34..b9213c8259 100644
--- a/runtime/lua/man.lua
+++ b/runtime/lua/man.lua
@@ -479,7 +479,13 @@ local function put_page(page)
-- XXX: nroff justifies text by filling it with whitespace. That interacts
-- badly with our use of $MANWIDTH=999. Hack around this by using a fixed
-- size for those whitespace regions.
- vim.cmd([[silent! keeppatterns keepjumps %s/\s\{199,}/\=repeat(' ', 10)/g]])
+ -- Use try/catch to avoid setting v:errmsg.
+ vim.cmd([[
+ try
+ keeppatterns keepjumps %s/\s\{199,}/\=repeat(' ', 10)/g
+ catch
+ endtry
+ ]])
vim.cmd('1') -- Move cursor to first line
highlight_man_page()
set_options()
diff --git a/test/functional/plugin/man_spec.lua b/test/functional/plugin/man_spec.lua
index 5e4ec53f8d..c0256d1c63 100644
--- a/test/functional/plugin/man_spec.lua
+++ b/test/functional/plugin/man_spec.lua
@@ -20,7 +20,7 @@ local function get_search_history(name)
local args = vim.split(name, ' ')
local code = [[
local args = ...
- local man = require('runtime.lua.man')
+ local man = require('man')
local res = {}
man.find_path = function(sect, name)
table.insert(res, {sect, name})