Fix command line function
parent
4a86faa121
commit
59f9401455
|
|
@ -66,17 +66,15 @@ function M.in_and_out_cmd()
|
||||||
local current_pos = vim.fn.getcmdpos()
|
local current_pos = vim.fn.getcmdpos()
|
||||||
local target_pos = nil
|
local target_pos = nil
|
||||||
local line = vim.fn.getcmdline()
|
local line = vim.fn.getcmdline()
|
||||||
vim.notify(current_pos .. line)
|
|
||||||
for _, char in ipairs(targets) do
|
for _, char in ipairs(targets) do
|
||||||
local found_pos = string.find(line, escape_lua_pattern(char), current_pos)
|
local found_pos = string.find(line, escape_lua_pattern(char), current_pos)
|
||||||
if found_pos and (not target_pos or found_pos < target_pos) then
|
if found_pos and (not target_pos or found_pos < target_pos) then
|
||||||
-- If char is a multibyte character, we need to take into account the extra bytes.
|
-- If char is a multibyte character, we need to take into account the extra bytes.
|
||||||
target_pos = found_pos + vim.fn.strlen(char) -- 1
|
target_pos = found_pos + vim.fn.strlen(char)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if target_pos then
|
if target_pos then
|
||||||
vim.fn.setcmdline(line, target_pos)
|
vim.fn.setcmdline(line, target_pos)
|
||||||
end
|
end
|
||||||
-- vim.fn.setcmdpos(1)
|
|
||||||
end
|
end
|
||||||
return M
|
return M
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue