mirror of
https://github.com/folke/snacks.nvim
synced 2025-08-04 18:58:12 +00:00
fix(picker.git_branches): handle detached HEAD (#671)
## Description Handle [detached HEAD](https://git-scm.com/docs/git-checkout#_detached_head) - list: display correct information - preview: without error notification - action: checkout the commit that HEAD detached at <!-- Describe the big picture of your changes to communicate to the maintainers why we should accept this pull request. --> ## Related Issue(s) <!-- If this PR fixes any issues, please link to the issue here. - Fixes #<issue_number> --> - Fixes #672 ## Screenshots <!-- Add screenshots of the changes if applicable. --> Before: <img width="1308" alt="image" src="https://github.com/user-attachments/assets/fad291a3-a730-4a2b-9eb2-4a0edd83d794" /> After: <img width="1038" alt="image" src="https://github.com/user-attachments/assets/d312579a-e12d-4286-845c-a706d91a6c95" /> --------- Co-authored-by: Folke Lemaitre <folke.lemaitre@gmail.com>
This commit is contained in:
parent
a1c78a2459
commit
390f687431
4 changed files with 32 additions and 8 deletions
|
@ -138,9 +138,12 @@ function M.git_branch(item, picker)
|
|||
local ret = {} ---@type snacks.picker.Highlight[]
|
||||
if item.current then
|
||||
ret[#ret + 1] = { a("", 2), "SnacksPickerGitBranchCurrent" }
|
||||
ret[#ret + 1] = { a(item.branch, 30, { truncate = true }), "SnacksPickerGitBranch" }
|
||||
else
|
||||
ret[#ret + 1] = { a("", 2) }
|
||||
end
|
||||
if item.detached then
|
||||
ret[#ret + 1] = { a("(detached HEAD)", 30, { truncate = true }), "SnacksPickerGitDetached" }
|
||||
else
|
||||
ret[#ret + 1] = { a(item.branch, 30, { truncate = true }), "SnacksPickerGitBranch" }
|
||||
end
|
||||
ret[#ret + 1] = { " " }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue