mirror of
https://github.com/zoriya/jj.nvim.git
synced 2026-08-15 23:53:18 +00:00
fix(filesets): Correclty escape filesets in different commands to avoid
special characters breaking jj's parsing
This commit is contained in:
@@ -20,7 +20,9 @@ function M.resolve(opts)
|
||||
-- Extra arguments
|
||||
vim.list_extend(cmd_args, args)
|
||||
-- Append the filestes
|
||||
vim.list_extend(cmd_args, filesets)
|
||||
for _, fileset in ipairs(filesets) do
|
||||
table.insert(cmd_args, utils.escape_fileset(fileset))
|
||||
end
|
||||
|
||||
local escaped_cmd_args = {}
|
||||
for _, arg in ipairs(cmd_args) do
|
||||
|
||||
@@ -25,7 +25,7 @@ local function build_split_command(opts)
|
||||
|
||||
if opts.filesets then
|
||||
for _, fileset in ipairs(opts.filesets) do
|
||||
table.insert(args, fileset)
|
||||
table.insert(args, utils.escape_fileset(fileset))
|
||||
end
|
||||
end
|
||||
|
||||
@@ -39,8 +39,7 @@ function M.split(opts)
|
||||
return
|
||||
end
|
||||
|
||||
local cmd_mod = require("jj.cmd")
|
||||
opts = vim.tbl_deep_extend("force", cmd_mod.config.split or {}, opts or {}) --[[@as jj.cmd.split.opts]]
|
||||
opts = opts or {} --[[@as jj.cmd.split.opts]]
|
||||
|
||||
-- If it's empty do nothing
|
||||
if utils.is_change_empty(opts.rev or "@") then
|
||||
|
||||
@@ -16,8 +16,8 @@ function M.handle_status_restore()
|
||||
|
||||
if file_info.is_rename then
|
||||
-- For renamed files, remove the new file and restore the old one from parent revision
|
||||
local rm_cmd = "rm " .. vim.fn.shellescape(file_info.new_path)
|
||||
local restore_cmd = "jj restore --from @- " .. vim.fn.shellescape(file_info.old_path)
|
||||
local rm_cmd = string.format("rm %s", vim.fn.shellescape(file_info.new_path))
|
||||
local restore_cmd = string.format("jj restore --from @- %s", utils.escape_fileset(file_info.old_path))
|
||||
|
||||
local _, rm_success = runner.execute_command(rm_cmd, "Failed to remove renamed file")
|
||||
if rm_success then
|
||||
@@ -32,7 +32,8 @@ function M.handle_status_restore()
|
||||
end
|
||||
else
|
||||
-- For non-renamed files, use regular restore
|
||||
local restore_cmd = "jj restore " .. vim.fn.shellescape(file_info.old_path)
|
||||
utils.notify(utils.escape_fileset(file_info.old_path))
|
||||
local restore_cmd = string.format("jj restore %s", utils.escape_fileset(file_info.old_path))
|
||||
|
||||
local _, success = runner.execute_command(restore_cmd, "Failed to restore")
|
||||
if success then
|
||||
|
||||
Reference in New Issue
Block a user