Escape metacharacters when loading file into cmdline (#196)
* Escape metacharacters when loading file into cmdline * format: apply stylua --------- Co-authored-by: Steven Arcangeli <stevearc@stevearc.com>
This commit is contained in:
parent
6cbc8d725d
commit
a8ac4dee48
1 changed files with 6 additions and 10 deletions
|
|
@ -224,14 +224,10 @@ M.refresh = {
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
local function open_cmdline_with_args(args)
|
local function open_cmdline_with_path(path)
|
||||||
local escaped = vim.api.nvim_replace_termcodes(
|
local escaped =
|
||||||
": " .. args .. string.rep("<Left>", args:len() + 1),
|
vim.api.nvim_replace_termcodes(": " .. vim.fn.fnameescape(path) .. "<Home>", true, false, true)
|
||||||
true,
|
vim.api.nvim_feedkeys(escaped, "n", false)
|
||||||
false,
|
|
||||||
true
|
|
||||||
)
|
|
||||||
vim.api.nvim_feedkeys(escaped, "n", true)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
M.open_cmdline = {
|
M.open_cmdline = {
|
||||||
|
|
@ -253,7 +249,7 @@ M.open_cmdline = {
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local fullpath = fs.shorten_path(fs.posix_to_os_path(path) .. entry.name)
|
local fullpath = fs.shorten_path(fs.posix_to_os_path(path) .. entry.name)
|
||||||
open_cmdline_with_args(fullpath)
|
open_cmdline_with_path(fullpath)
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -275,7 +271,7 @@ M.open_cmdline_dir = {
|
||||||
local fs = require("oil.fs")
|
local fs = require("oil.fs")
|
||||||
local dir = oil.get_current_dir()
|
local dir = oil.get_current_dir()
|
||||||
if dir then
|
if dir then
|
||||||
open_cmdline_with_args(fs.shorten_path(dir))
|
open_cmdline_with_path(fs.shorten_path(dir))
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue