mirror of
https://github.com/zoriya/jj.nvim.git
synced 2026-08-15 23:53:18 +00:00
Fixes default command parsing
This commit is contained in:
committed by
Nicolas GB
parent
3d78c28f7e
commit
d483544483
+6
-10
@@ -833,22 +833,18 @@ function M.j(args)
|
||||
local cmd = nil
|
||||
if #args == 0 then
|
||||
local default_cmd_str, success = runner.execute_command(
|
||||
"jj config get ui.default-command",
|
||||
"jj config list ui.default-command",
|
||||
"Error getting user's default command",
|
||||
nil,
|
||||
true
|
||||
)
|
||||
if not success then
|
||||
terminal.run("jj", M.terminal_keymaps())
|
||||
return
|
||||
if success then
|
||||
cmd = parser.parse_default_cmd(default_cmd_str or "")
|
||||
end
|
||||
|
||||
local default_cmd = parser.parse_default_cmd(default_cmd_str and default_cmd_str or "")
|
||||
if default_cmd == nil then
|
||||
terminal.run("jj", M.terminal_keymaps())
|
||||
return
|
||||
-- jj's built-in default command is "log"
|
||||
if cmd == nil then
|
||||
cmd = { "log" }
|
||||
end
|
||||
cmd = default_cmd
|
||||
end
|
||||
|
||||
if type(args) == "string" then
|
||||
|
||||
@@ -9,8 +9,9 @@ function M.parse_default_cmd(cmd_output)
|
||||
return nil
|
||||
end
|
||||
|
||||
-- Remove whitespace and parse TOML output
|
||||
-- Remove whitespace and strip "key = " prefix from `jj config list` output
|
||||
local trimmed_cmd = vim.trim(cmd_output)
|
||||
trimmed_cmd = trimmed_cmd:gsub("^[%w._-]+ = ", "")
|
||||
|
||||
-- Try to parse as TOML array: ["item1", "item2", ...]
|
||||
-- Pattern "%[(.*)%]" captures everything between square brackets
|
||||
|
||||
Reference in New Issue
Block a user