mirror of
https://github.com/neovim/neovim.git
synced 2025-10-26 12:27:24 +00:00
test: Rename meth_pcall to pcall_err
- Rename `meth_pcall`. - Make `pcall_err` raise an error if the function does not fail. - Add `vim.pesc()` to treat a string as literal where a Lua pattern is expected.
This commit is contained in:
@@ -178,9 +178,20 @@ local function trim(s)
|
||||
return s:match('^%s*(.*%S)') or ''
|
||||
end
|
||||
|
||||
--- Escapes magic chars in a Lua pattern string.
|
||||
---
|
||||
--@see https://github.com/rxi/lume
|
||||
--@param s String to escape
|
||||
--@returns %-escaped pattern string
|
||||
local function pesc(s)
|
||||
assert(type(s) == 'string')
|
||||
return s:gsub('[%(%)%.%%%+%-%*%?%[%]%^%$]', '%%%1')
|
||||
end
|
||||
|
||||
local module = {
|
||||
deepcopy = deepcopy,
|
||||
gsplit = gsplit,
|
||||
pesc = pesc,
|
||||
split = split,
|
||||
tbl_contains = tbl_contains,
|
||||
tbl_extend = tbl_extend,
|
||||
|
||||
Reference in New Issue
Block a user