Skip to content

Commit

Permalink
Highlight the most recent stash item in green in the stash view
Browse files Browse the repository at this point in the history
...as long as the statusMessage is `Stashed!` is present
  • Loading branch information
penguwin authored and meowgorithm committed Dec 24, 2020
1 parent a0fb0e4 commit 8f3c5df
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
30 changes: 22 additions & 8 deletions ui/stashitem.go
Expand Up @@ -68,20 +68,34 @@ func stashItemView(b *strings.Builder, m stashModel, index int, md *markdown) {
title = m.noteInput.View()
date = dullYellowFg(date)
default:
gutter = dullFuchsiaFg(verticalLine)
icon = dullFuchsiaFg(icon)
if m.currentSection().key == filterSection && m.filterState == filterApplied || singleFilteredItem {
s := termenv.Style{}.Foreground(lib.Fuschia.Color())
title = styleFilteredText(title, m.filterInput.Value(), s, s.Underline())
if m.common.latestFileStashed == md.stashID &&
m.statusMessage == stashedStatusMessage {
gutter = greenFg(verticalLine)
icon = dimGreenFg(icon)
title = greenFg(title)
date = dimGreenFg(date)
} else {
title = fuchsiaFg(title)
gutter = dullFuchsiaFg(verticalLine)
icon = dullFuchsiaFg(icon)
if m.currentSection().key == filterSection && m.filterState == filterApplied || singleFilteredItem {
s := termenv.Style{}.Foreground(lib.Fuschia.Color())
title = styleFilteredText(title, m.filterInput.Value(), s, s.Underline())
} else {
title = fuchsiaFg(title)
}
date = dullFuchsiaFg(date)
}
date = dullFuchsiaFg(date)
}
} else {
// Regular (non-selected) items

if md.docType == NewsDoc {
if m.common.latestFileStashed == md.stashID &&
m.statusMessage == stashedStatusMessage {
gutter = " "
icon = dimGreenFg(icon)
title = greenFg(title)
date = dimGreenFg(date)
} else if md.docType == NewsDoc {
gutter = " "

if isFiltering && m.filterInput.Value() == "" {
Expand Down
4 changes: 4 additions & 0 deletions ui/ui.go
Expand Up @@ -137,6 +137,9 @@ type commonModel struct {
// ignoring the value portion with an empty struct.
filesStashed map[ksuid.KSUID]struct{}

// ID of the most recently stashed markdown
latestFileStashed ksuid.KSUID

// Files currently being stashed. We remove files from this set once
// a stash operation has either succeeded or failed.
filesStashing map[ksuid.KSUID]struct{}
Expand Down Expand Up @@ -407,6 +410,7 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
md := markdown(msg)
m.stash.addMarkdowns(&md)
m.common.filesStashed[msg.stashID] = struct{}{}
m.common.latestFileStashed = msg.stashID
delete(m.common.filesStashing, md.stashID)

if m.stash.filterApplied() {
Expand Down

0 comments on commit 8f3c5df

Please sign in to comment.