Skip to content

Commit 4fd641c

Browse files
Willem-J-ancraigmac
authored andcommitted
fix(branch): extract correct branch name for term buffers (nvim-lualine#1204)
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.
1 parent 5edf038 commit 4fd641c

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lua/lualine/components/branch/git_branch.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@ function M.find_git_dir(dir_path)
7676

7777
-- get file dir so we can search from that dir
7878
local file_dir = dir_path or vim.fn.expand('%:p:h')
79+
80+
-- extract correct file dir from terminals
81+
if file_dir and file_dir:match('term://.*') then
82+
file_dir = vim.fn.expand(file_dir:gsub('term://(.+)//.+', "%1"))
83+
end
84+
7985
local root_dir = file_dir
8086
-- Search upward for .git file or folder
8187
while root_dir do

0 commit comments

Comments
 (0)