summaryrefslogtreecommitdiffstats
path: root/pkg/gui/presentation
diff options
context:
space:
mode:
authorJoel Baranick <joel.baranick@ensighten.com>2022-09-02 09:35:08 -0700
committerJesse Duffield <jessedduffield@gmail.com>2023-07-30 18:35:21 +1000
commitc679fd1924e9669a30d038fbdd164d948393c301 (patch)
treedac9a92eb38ee225d90c98446bf16067051e6c8b /pkg/gui/presentation
parent9a79154d05a81852a36ed336b6927ef60f835d6b (diff)
Style missing worktree as red and display better error when trying to switch to them
Use a broken link icon for missing worktrees
Diffstat (limited to 'pkg/gui/presentation')
-rw-r--r--pkg/gui/presentation/icons/git_icons.go24
-rw-r--r--pkg/gui/presentation/worktrees.go12
2 files changed, 23 insertions, 13 deletions
diff --git a/pkg/gui/presentation/icons/git_icons.go b/pkg/gui/presentation/icons/git_icons.go
index 6b5689295..f6b56284e 100644
--- a/pkg/gui/presentation/icons/git_icons.go
+++ b/pkg/gui/presentation/icons/git_icons.go
@@ -7,14 +7,15 @@ import (
)
var (
- BRANCH_ICON = "\U000f062c" // 󰘬
- DETACHED_HEAD_ICON = "\ue729" // 
- TAG_ICON = "\uf02b" // 
- COMMIT_ICON = "\U000f0718" // 󰜘
- MERGE_COMMIT_ICON = "\U000f062d" // 󰘭
- DEFAULT_REMOTE_ICON = "\uf02a2" // 󰊢
- STASH_ICON = "\uf01c" // 
- LINKED_WORKTREE_ICON = "\uf838" // 
+ BRANCH_ICON = "\U000f062c" // 󰘬
+ DETACHED_HEAD_ICON = "\ue729" // 
+ TAG_ICON = "\uf02b" // 
+ COMMIT_ICON = "\U000f0718" // 󰜘
+ MERGE_COMMIT_ICON = "\U000f062d" // 󰘭
+ DEFAULT_REMOTE_ICON = "\uf02a2" // 󰊢
+ STASH_ICON = "\uf01c" // 
+ LINKED_WORKTREE_ICON = "\uf838" // 
+ MISSING_LINKED_WORKTREE_ICON = "\uf839" // 
)
var remoteIcons = map[string]string{
@@ -70,9 +71,12 @@ func IconForStash(stash *models.StashEntry) string {
return STASH_ICON
}
-func IconForWorktree(worktree *models.Worktree) string {
- if worktree.Main {
+func IconForWorktree(worktree *models.Worktree, missing bool) string {
+ if worktree.Main() {
return ""
}
+ if missing {
+ return MISSING_LINKED_WORKTREE_ICON
+ }
return LINKED_WORKTREE_ICON
}
diff --git a/pkg/gui/presentation/worktrees.go b/pkg/gui/presentation/worktrees.go
index 4bb778944..cf7b08938 100644
--- a/pkg/gui/presentation/worktrees.go
+++ b/pkg/gui/presentation/worktrees.go
@@ -20,16 +20,22 @@ func getWorktreeDisplayStrings(w *models.Worktree) []string {
current := ""
currentColor := style.FgCyan
- if w.Current {
+ if w.Current() {
current = " *"
currentColor = style.FgGreen
}
+ icon := icons.IconForWorktree(w, false)
+ if w.Missing() {
+ textStyle = style.FgRed
+ icon = icons.IconForWorktree(w, true)
+ }
+
res := make([]string, 0, 3)
res = append(res, currentColor.Sprint(current))
if icons.IsIconEnabled() {
- res = append(res, textStyle.Sprint(icons.IconForWorktree(w)))
+ res = append(res, textStyle.Sprint(icon))
}
- res = append(res, textStyle.Sprint(w.Name))
+ res = append(res, textStyle.Sprint(w.Name()))
return res
}