From 8f3c5df236b803c85a2eb14bd6d0245aa3872d2d Mon Sep 17 00:00:00 2001 From: Nicolas Martin Date: Thu, 17 Dec 2020 21:45:08 +0100 Subject: [PATCH] Highlight the most recent stash item in green in the stash view ...as long as the statusMessage is `Stashed!` is present --- ui/stashitem.go | 30 ++++++++++++++++++++++-------- ui/ui.go | 4 ++++ 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/ui/stashitem.go b/ui/stashitem.go index 65a44f3..414f439 100644 --- a/ui/stashitem.go +++ b/ui/stashitem.go @@ -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() == "" { diff --git a/ui/ui.go b/ui/ui.go index 522de57..4f21aea 100644 --- a/ui/ui.go +++ b/ui/ui.go @@ -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{} @@ -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() {