summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorZhizhen He <hezhizhen.yi@gmail.com>2024-05-18 16:06:33 +0800
committerGitHub <noreply@github.com>2024-05-18 17:06:33 +0900
commit01e7668915c4e3cf8c9eeca283d41beac924fe1f (patch)
tree721306578106c58da6cdb0c04543eaba53b7d5a1 /src
parent0994d9c881f8380997b96bb0a4a7416b50bc2b0d (diff)
chore: use strings.ReplaceAll (#3801)
Diffstat (limited to 'src')
-rw-r--r--src/ansi_test.go4
-rw-r--r--src/options.go8
-rw-r--r--src/pattern.go4
-rw-r--r--src/terminal.go2
-rw-r--r--src/tui/light.go2
-rw-r--r--src/util/util_windows.go6
6 files changed, 13 insertions, 13 deletions
diff --git a/src/ansi_test.go b/src/ansi_test.go
index b5481e5f..55f7fc08 100644
--- a/src/ansi_test.go
+++ b/src/ansi_test.go
@@ -342,8 +342,8 @@ func TestAnsiCodeStringConversion(t *testing.T) {
state := interpretCode(code, prevState)
if expected != state.ToString() {
t.Errorf("expected: %s, actual: %s",
- strings.Replace(expected, "\x1b[", "\\x1b[", -1),
- strings.Replace(state.ToString(), "\x1b[", "\\x1b[", -1))
+ strings.ReplaceAll(expected, "\x1b[", "\\x1b["),
+ strings.ReplaceAll(state.ToString(), "\x1b[", "\\x1b["))
}
}
assert("\x1b[m", nil, "")
diff --git a/src/options.go b/src/options.go
index 83b0e97f..0265693a 100644
--- a/src/options.go
+++ b/src/options.go
@@ -554,7 +554,7 @@ func splitNth(str string) ([]Range, error) {
func delimiterRegexp(str string) Delimiter {
// Special handling of \t
- str = strings.Replace(str, "\\t", "\t", -1)
+ str = strings.ReplaceAll(str, "\\t", "\t")
// 1. Pattern does not contain any special character
if regexp.QuoteMeta(str) == str {
@@ -1132,9 +1132,9 @@ Loop:
masked += strings.Repeat(" ", loc[1])
action = action[loc[1]:]
}
- masked = strings.Replace(masked, "::", string([]rune{escapedColon, ':'}), -1)
- masked = strings.Replace(masked, ",:", string([]rune{escapedComma, ':'}), -1)
- masked = strings.Replace(masked, "+:", string([]rune{escapedPlus, ':'}), -1)
+ masked = strings.ReplaceAll(masked, "::", string([]rune{escapedColon, ':'}))
+ masked = strings.ReplaceAll(masked, ",:", string([]rune{escapedComma, ':'}))
+ masked = strings.ReplaceAll(masked, "+:", string([]rune{escapedPlus, ':'}))
return masked
}
diff --git a/src/pattern.go b/src/pattern.go
index cbe73dc4..ee1b88a5 100644
--- a/src/pattern.go
+++ b/src/pattern.go
@@ -155,14 +155,14 @@ func BuildPattern(cache *ChunkCache, patternCache map[string]*Pattern, fuzzy boo
}
func parseTerms(fuzzy bool, caseMode Case, normalize bool, str string) []termSet {
- str = strings.Replace(str, "\\ ", "\t", -1)
+ str = strings.ReplaceAll(str, "\\ ", "\t")
tokens := _splitRegex.Split(str, -1)
sets := []termSet{}
set := termSet{}
switchSet := false
afterBar := false
for _, token := range tokens {
- typ, inv, text := termFuzzy, false, strings.Replace(token, "\t", " ", -1)
+ typ, inv, text := termFuzzy, false, strings.ReplaceAll(token, "\t", " ")
lowerText := strings.ToLower(text)
caseSensitive := caseMode == CaseRespect ||
caseMode == CaseSmart && text != lowerText
diff --git a/src/terminal.go b/src/terminal.go
index fe30161c..87178a77 100644
--- a/src/terminal.go
+++ b/src/terminal.go
@@ -618,7 +618,7 @@ func defaultKeymap() map[tui.Event][]*action {
}
func trimQuery(query string) []rune {
- return []rune(strings.Replace(query, "\t", " ", -1))
+ return []rune(strings.ReplaceAll(query, "\t", " "))
}
func mayTriggerPreview(opts *Options) bool {
diff --git a/src/tui/light.go b/src/tui/light.go
index 4d3f58a4..1181d167 100644
--- a/src/tui/light.go
+++ b/src/tui/light.go
@@ -1025,7 +1025,7 @@ func (w *LightWindow) Print(text string) {
}
func cleanse(str string) string {
- return strings.Replace(str, "\x1b", "", -1)
+ return strings.ReplaceAll(str, "\x1b", "")
}
func (w *LightWindow) CPrint(pair ColorPair, text string) {
diff --git a/src/util/util_windows.go b/src/util/util_windows.go
index 3a4ab570..d9db8342 100644
--- a/src/util/util_windows.go
+++ b/src/util/util_windows.go
@@ -157,10 +157,10 @@ func (x *Executor) QuoteEntry(entry string) string {
*/
return escapeArg(entry)
case shellTypePowerShell:
- escaped := strings.Replace(entry, `"`, `\"`, -1)
- return "'" + strings.Replace(escaped, "'", "''", -1) + "'"
+ escaped := strings.ReplaceAll(entry, `"`, `\"`)
+ return "'" + strings.ReplaceAll(escaped, "'", "''") + "'"
default:
- return "'" + strings.Replace(entry, "'", "'\\''", -1) + "'"
+ return "'" + strings.ReplaceAll(entry, "'", "'\\''") + "'"
}
}