refactor(git): load git:// URI buffers via BufReadCmd

This commit is contained in:
2026-04-28 07:34:07 +02:00
parent 4f7edfa184
commit f8cf18a2c0
5 changed files with 127 additions and 95 deletions
+5 -14
View File
@@ -485,14 +485,14 @@ end
local function head_pane(worktree, path)
return {
buf = diff.git_show_buf(worktree, "HEAD", path),
name = "git://HEAD/" .. path,
name = "git://HEAD//" .. path,
}
end
---@param path string
---@return ow.Git.DiffSide
local function head_empty_pane(path)
return { buf = diff.empty_buf(), name = "git://HEAD/" .. path }
return { buf = diff.empty_buf(), name = "git://HEAD//" .. path }
end
---@param worktree string
@@ -508,7 +508,7 @@ end
---@param path string
---@return ow.Git.DiffSide
local function worktree_empty_pane(path)
return { buf = diff.empty_buf(), name = "git://worktree/" .. path }
return { buf = diff.empty_buf(), name = "git://worktree//" .. path }
end
---@param s ow.Git.SidebarState
@@ -520,9 +520,9 @@ local function index_pane(s, entry)
or (entry.section == "Staged" and entry.x == "D")
)
return {
buf = in_index and diff.git_show_buf(s.worktree, "", entry.path, true)
buf = in_index and diff.git_show_buf(s.worktree, "index", entry.path)
or diff.empty_buf(),
name = "git://index/" .. entry.path,
name = "git://index//" .. entry.path,
}
end
@@ -727,15 +727,6 @@ local function show_diff(s, entry, focus_left)
diff.set_buf_name_and_filetype(side.buf, side.name)
end
end
-- Synthetic index/HEAD buffers never run BufRead, so modeline-only
-- filetypes aren't detected. Copy from the side that did resolve.
local left_ft = vim.bo[pair.left.buf].filetype
local right_ft = vim.bo[pair.right.buf].filetype
if left_ft == "" and right_ft ~= "" then
vim.bo[pair.left.buf].filetype = right_ft
elseif right_ft == "" and left_ft ~= "" then
vim.bo[pair.right.buf].filetype = left_ft
end
diff.set_diff(left_win, true)
diff.set_diff(right_win, true)
s.last_shown_key = key