From 3b87d84ca912f54321652c16b7a7cbe2c441c126 Mon Sep 17 00:00:00 2001 From: Oscar Wallberg Date: Mon, 27 Apr 2026 13:57:40 +0200 Subject: [PATCH] refactor(git): drop boolean params from pane constructors --- lua/git/status_win.lua | 43 +++++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/lua/git/status_win.lua b/lua/git/status_win.lua index 8588677..29dacdc 100644 --- a/lua/git/status_win.lua +++ b/lua/git/status_win.lua @@ -383,27 +383,33 @@ end ---@param worktree string ---@param path string ----@param content boolean ---@return ow.Git.DiffSide -local function head_pane(worktree, path, content) +local function head_pane(worktree, path) return { - buf = content and diff.git_show_buf(worktree, "HEAD", path) - or diff.empty_buf(), + buf = diff.git_show_buf(worktree, "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 } +end + ---@param worktree string ---@param path string ----@param exists boolean ---@return ow.Git.DiffSide -local function worktree_pane(worktree, path, exists) - if exists then - return { - buf = diff.load_file_buf(vim.fs.joinpath(worktree, path)), - name = nil, - } - end +local function worktree_pane(worktree, path) + return { + buf = diff.load_file_buf(vim.fs.joinpath(worktree, path)), + name = nil, + } +end + +---@param path string +---@return ow.Git.DiffSide +local function worktree_empty_pane(path) return { buf = diff.empty_buf(), name = "git://worktree/" .. path } end @@ -430,19 +436,22 @@ local function other_pane(s, entry) local worktree = s.worktree if entry.section == "Staged" then if entry.x == "A" then - return head_pane(worktree, p, false) + return head_empty_pane(p) end if entry.x == "D" then - return head_pane(worktree, p, true) + return head_pane(worktree, p) end -- HEAD holds the pre-rename path - return head_pane(worktree, entry.orig or p, true) + return head_pane(worktree, entry.orig or p) end if entry.section == "Unstaged" then - return worktree_pane(worktree, p, entry.y ~= "D") + if entry.y == "D" then + return worktree_empty_pane(p) + end + return worktree_pane(worktree, p) end if entry.section == "Untracked" then - return worktree_pane(worktree, p, true) + return worktree_pane(worktree, p) end end