From b0ef071e9443b75cf876f87a220b0a103a83e124 Mon Sep 17 00:00:00 2001 From: Camille Scholtz Date: Tue, 28 Jun 2016 19:55:29 +0200 Subject: [PATCH] command.go: Simplify and prettify replace feedback --- cmd/micro/command.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cmd/micro/command.go b/cmd/micro/command.go index d27f914b..2d389f9e 100644 --- a/cmd/micro/command.go +++ b/cmd/micro/command.go @@ -143,15 +143,13 @@ func Replace(args []string) { view := CurView() - found := false - count := 0 + found := 0 for { match := regex.FindStringIndex(view.Buf.String()) if match == nil { break } - found = true - count = count + 1 + found = found + 1 if strings.Contains(flags, "c") { // The 'check' flag was used Search(search, view, true) @@ -186,8 +184,10 @@ func Replace(args []string) { view.Buf.Replace(FromCharPos(match[0], view.Buf), FromCharPos(match[1], view.Buf), replace) } } - if found { - messenger.Message("Replaced " + strconv.Itoa(count) + " occurences") + if found > 1 { + messenger.Message("Replaced " + strconv.Itoa(found) + " occurences of " + search) + } else if found == 1 { + messenger.Message("Replaced " + strconv.Itoa(found) + " occurence of " + search) } else { messenger.Message("Nothing matched " + search) }