mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-16 05:47:06 +09:00
command.go: Simplify and prettify replace feedback
This commit is contained in:
@@ -143,15 +143,13 @@ func Replace(args []string) {
|
|||||||
|
|
||||||
view := CurView()
|
view := CurView()
|
||||||
|
|
||||||
found := false
|
found := 0
|
||||||
count := 0
|
|
||||||
for {
|
for {
|
||||||
match := regex.FindStringIndex(view.Buf.String())
|
match := regex.FindStringIndex(view.Buf.String())
|
||||||
if match == nil {
|
if match == nil {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
found = true
|
found = found + 1
|
||||||
count = count + 1
|
|
||||||
if strings.Contains(flags, "c") {
|
if strings.Contains(flags, "c") {
|
||||||
// The 'check' flag was used
|
// The 'check' flag was used
|
||||||
Search(search, view, true)
|
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)
|
view.Buf.Replace(FromCharPos(match[0], view.Buf), FromCharPos(match[1], view.Buf), replace)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if found {
|
if found > 1 {
|
||||||
messenger.Message("Replaced " + strconv.Itoa(count) + " occurences")
|
messenger.Message("Replaced " + strconv.Itoa(found) + " occurences of " + search)
|
||||||
|
} else if found == 1 {
|
||||||
|
messenger.Message("Replaced " + strconv.Itoa(found) + " occurence of " + search)
|
||||||
} else {
|
} else {
|
||||||
messenger.Message("Nothing matched " + search)
|
messenger.Message("Nothing matched " + search)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user