feat(browse): support jj:// buffers

This commit is contained in:
2026-07-30 13:42:41 +02:00
parent e066efb140
commit 742cf28ce4
+17 -6
View File
@@ -61,10 +61,21 @@ function M.browse(opts)
return return
end end
local abs_path = vim.api.nvim_buf_get_name(0) local buf_name = vim.api.nvim_buf_get_name(0)
if not utils.is_file(abs_path) then -- `jj://` virtual buffers (opened via :Jedit) carry the revision and a
utils.notify("Current buffer is not a file", vim.log.levels.ERROR) -- cwd-relative path in their name rather than pointing at a real file.
return local jj_change_id, jj_path = utils.parse_jj_uri(buf_name)
local abs_path
if jj_path then
local cwd = vim.uv.cwd()
abs_path = cwd and vim.fs.joinpath(cwd, jj_path) or jj_path
else
abs_path = buf_name
if not utils.is_file(abs_path) then
utils.notify("Current buffer is not a file", vim.log.levels.ERROR)
return
end
end end
local root = utils.get_jj_root() local root = utils.get_jj_root()
@@ -88,7 +99,7 @@ function M.browse(opts)
line2 = line1 line2 = line1
end end
local revset = "@" local revset = jj_change_id or "@"
if opts then if opts then
if type(opts.args) == "string" and opts.args ~= "" then if type(opts.args) == "string" and opts.args ~= "" then
revset = vim.trim(opts.args) revset = vim.trim(opts.args)
@@ -116,7 +127,7 @@ function M.browse(opts)
-- If a revset has been given the walkback is none since the user doesn't expect any walkback -- If a revset has been given the walkback is none since the user doesn't expect any walkback
local max_walkback = 20 local max_walkback = 20
if revset ~= "@" then if revset ~= (jj_change_id or "@") then
max_walkback = 0 max_walkback = 0
end end