Skip to content

Commit

Permalink
fix(branch): extract correct branch name for term buffers (#1204)
Browse files Browse the repository at this point in the history
terminal buffers have a different path that did not work to retrieve the branch name. By extracting the path out of the terminal path, the branch name can still resolve even when in term buffers.
  • Loading branch information
Willem-J-an authored Mar 11, 2024
1 parent 8b56462 commit 79c4b29
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lua/lualine/components/branch/git_branch.lua
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ function M.find_git_dir(dir_path)

-- get file dir so we can search from that dir
local file_dir = dir_path or vim.fn.expand('%:p:h')

-- extract correct file dir from terminals
if file_dir and file_dir:match('term://.*') then
file_dir = vim.fn.expand(file_dir:gsub('term://(.+)//.+', "%1"))
end

local root_dir = file_dir
-- Search upward for .git file or folder
while root_dir do
Expand Down

0 comments on commit 79c4b29

Please sign in to comment.