diff --git a/cmd/update.go b/cmd/update.go index 0c0ed79..5c6c669 100644 --- a/cmd/update.go +++ b/cmd/update.go @@ -24,10 +24,6 @@ func Update(cmd *cobra.Command, args []string) { slog.Error("Failed releasing lock") } }() - // Disables the loading icon on the terminal - defer print("\033]9;4;0\a") - // Clears up any previous loading icon - print("\033]9;4;0\a") hwCheck, err := cmd.Flags().GetBool("hw-check") if err != nil { @@ -134,6 +130,7 @@ func Update(cmd *cobra.Command, args []string) { if progressEnabled { go pw.Render() + lib.ResetOscProgress() } // -1 because 0 index @@ -192,7 +189,10 @@ func Update(cmd *cobra.Command, args []string) { tracker.IncrementSection(err) } - pw.Stop() + if progressEnabled { + pw.Stop() + lib.ResetOscProgress() + } if verboseRun { slog.Info("Verbose run requested") diff --git a/lib/percentmanager.go b/lib/percentmanager.go index 57ed8f3..df03aff 100644 --- a/lib/percentmanager.go +++ b/lib/percentmanager.go @@ -62,8 +62,6 @@ type TrackerMessage struct { } func ChangeTrackerMessageFancy(writer progress.Writer, tracker *IncrementTracker, progress bool, message TrackerMessage) { - percentage := math.Round((float64(tracker.Tracker.Value()) / float64(tracker.Tracker.Total)) * 100) - fmt.Printf("\033]9;4;1;%d\a", int(percentage)) if !progress { slog.Info("Updating", slog.String("title", message.Title), @@ -73,6 +71,8 @@ func ChangeTrackerMessageFancy(writer progress.Writer, tracker *IncrementTracker ) return } + percentage := math.Round((float64(tracker.Tracker.Value()) / float64(tracker.Tracker.Total)) * 100) + fmt.Printf("\033]9;4;1;%d\a", int(percentage)) finalMessage := fmt.Sprintf("Updating %s (%s)", message.Description, message.Title) writer.SetMessageLength(len(finalMessage)) tracker.Tracker.UpdateMessage(finalMessage) @@ -96,3 +96,9 @@ func (it *IncrementTracker) IncrementSection(err error) { func (it *IncrementTracker) CurrentStep() int { return it.incrementer.doneIncrements } + +func ResetOscProgress() { + // OSC escape sequence to reset all previous OSC progress hints to 0%. + // Documentation is on https://conemu.github.io/en/AnsiEscapeCodes.html#ConEmu_specific_OSC + print("\033]9;4;0\a") +}