feat(cmd): Add option to set describe type for cmd

Adds the global option `describe.editor.type` to the exposed describe
command api, so it can be executed e.g. with:

`require("jj.cmd").describe(nil,nil,{with_status=false,type="input"})`

This allows having different types of describe commands invoked in a
single setting, without having to change the global plugin option.

Takes the same two option enums as the global variable, "buffer" or
"input". Is an optional field, which is given precedence to the older
order of setting the variable. That order remains the same.
This commit is contained in:
Marty Oehme
2026-01-11 23:17:37 +01:00
committed by Nicolas GB
parent 80d3a88f16
commit d13a5c9aec
+3 -2
View File
@@ -9,6 +9,7 @@ local editor = require("jj.ui.editor")
--- @class jj.cmd.describe_opts
--- @field with_status boolean: Whether or not `jj st` should be displayed in a buffer while describing the commit
--- @field type? "buffer"|"input" Editor mode for describe command: "buffer" (Git-style editor) or "input" (simple input prompt)
--- @type jj.cmd.describe_opts
local default_describe_opts = {
with_status = true,
@@ -69,9 +70,10 @@ function M.describe(description, revset, opts)
end
local cmd = require("jj.cmd")
local merged_opts = vim.tbl_deep_extend("force", default_describe_opts, opts or {})
-- Use buffer editor mode (defaults to "buffer" if not configured)
local editor_mode = cmd.config.describe.editor.type or "buffer"
local editor_mode = merged_opts.type or cmd.config.describe.editor.type or "buffer"
if editor_mode == "buffer" then
local jj_cmd = "jj log -r " .. revset .. " --no-graph -T 'coalesce(description, \"\n\")'"
local old_description_raw, success = runner.execute_command(jj_cmd, "Failed to get old description")
@@ -129,7 +131,6 @@ function M.describe(description, revset, opts)
end, describe_editor_keymaps())
else
-- Use input mode
local merged_opts = vim.tbl_deep_extend("force", default_describe_opts, opts or {})
if merged_opts.with_status then
-- Show the status in a terminal buffer
cmd.status()