From 6def99ce24e6071ee937a5c093a07b83467050f7 Mon Sep 17 00:00:00 2001 From: Zachary Yedidia Date: Tue, 24 Mar 2020 11:14:54 -0400 Subject: [PATCH] Clarify replace message if replacing in selection --- internal/action/command.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/internal/action/command.go b/internal/action/command.go index cbfdec29..ec4da484 100644 --- a/internal/action/command.go +++ b/internal/action/command.go @@ -733,7 +733,8 @@ func (h *BufPane) ReplaceCmd(args []string) { nreplaced := 0 start := h.Buf.Start() end := h.Buf.End() - if h.Cursor.HasSelection() { + selection := h.Cursor.HasSelection() + if selection { start = h.Cursor.CurSelection[0] end = h.Cursor.CurSelection[1] } @@ -786,13 +787,20 @@ func (h *BufPane) ReplaceCmd(args []string) { h.Buf.RelocateCursors() + var s string if nreplaced > 1 { - InfoBar.Message("Replaced ", nreplaced, " occurrences of ", search) + s = fmt.Sprintf("Replaced %d occurrences of %s", nreplaced, search) } else if nreplaced == 1 { - InfoBar.Message("Replaced ", nreplaced, " occurrence of ", search) + s = fmt.Sprintf("Replaced 1 occurrence of %s", search) } else { - InfoBar.Message("Nothing matched ", search) + s = fmt.Sprintf("Nothing matched %s", search) } + + if selection { + s += " in selection" + } + + InfoBar.Message(s) } // ReplaceAllCmd replaces search term all at once