chore: use strings.ReplaceAll (#3801)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Zhizhen He · committed by GitHub · parent 0994d9c · Browse files · 6 files·+13 added−13 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
6 files+13 added−13 removed
- other:+13 added−13 removed
Provenance
- Commit
01e7668- Tree
7213065- Author
Zhizhen He <hezhizhen.yi@gmail.com>- Committer
GitHub <noreply@github.com>- Parent
0994d9c
6 files changed+13 added−13 removed
modified:src/tui/light.go+1 added-1 removed
1023 unmodified lines1024 w.cprint2(colDefault, w.bg, AttrRegular, text)1025 }1026 1027 func cleanse(str string) string {1028- return strings.Replace(str, "\x1b", "", -1)1028+ return strings.ReplaceAll(str, "\x1b", "")1029 }1030 1031 func (w *LightWindow) CPrint(pair ColorPair, text string) {1032 _, code := w.csiColor(pair.Fg(), pair.Bg(), pair.Attr())129 unmodified linesmodified:src/util/util_windows.go+3 added-3 removed
155 unmodified lines156 fd -H --no-ignore -td -d 4 | fzf --preview ".\eza.exe --color=always --tree --level=3 --icons=always {}" --with-shell "powershell -NoProfile -Command"157 */158 return escapeArg(entry)159 case shellTypePowerShell:160- escaped := strings.Replace(entry, `"`, `\"`, -1)161- return "'" + strings.Replace(escaped, "'", "''", -1) + "'"160+ escaped := strings.ReplaceAll(entry, `"`, `\"`)161+ return "'" + strings.ReplaceAll(escaped, "'", "''") + "'"162 default:163- return "'" + strings.Replace(entry, "'", "'\\''", -1) + "'"163+ return "'" + strings.ReplaceAll(entry, "'", "'\\''") + "'"164 }165 }166 167 // KillCommand kills the process for the given command22 unmodified linesmodified:src/ansi_test.go+2 added-2 removed
340 unmodified lines341 assert := func(code string, prevState *ansiState, expected string) {342 state := interpretCode(code, prevState)343 if expected != state.ToString() {344 t.Errorf("expected: %s, actual: %s",345- strings.Replace(expected, "\x1b[", "\\x1b[", -1),346- strings.Replace(state.ToString(), "\x1b[", "\\x1b[", -1))345+ strings.ReplaceAll(expected, "\x1b[", "\\x1b["),346+ strings.ReplaceAll(state.ToString(), "\x1b[", "\\x1b["))347 }348 }349 assert("\x1b[m", nil, "")350 assert("\x1b[m", &ansiState{attr: tui.Blink, lbg: -1}, "")81 unmodified linesmodified:src/options.go+4 added-4 removed
552 unmodified lines553 }554 555 func delimiterRegexp(str string) Delimiter {556 // Special handling of \t557- str = strings.Replace(str, "\\t", "\t", -1)557+ str = strings.ReplaceAll(str, "\\t", "\t")558 559 // 1. Pattern does not contain any special character560 if regexp.QuoteMeta(str) == str {561 return Delimiter{str: &str}569 unmodified lines1131 }1132 masked += strings.Repeat(" ", loc[1])1133 action = action[loc[1]:]1134 }1135- masked = strings.Replace(masked, "::", string([]rune{escapedColon, ':'}), -1)1136- masked = strings.Replace(masked, ",:", string([]rune{escapedComma, ':'}), -1)1137- masked = strings.Replace(masked, "+:", string([]rune{escapedPlus, ':'}), -1)1135+ masked = strings.ReplaceAll(masked, "::", string([]rune{escapedColon, ':'}))1136+ masked = strings.ReplaceAll(masked, ",:", string([]rune{escapedComma, ':'}))1137+ masked = strings.ReplaceAll(masked, "+:", string([]rune{escapedPlus, ':'}))1138 return masked1139 }1140 1141 func parseSingleActionList(str string) ([]*action, error) {1499 unmodified linesmodified:src/pattern.go+2 added-2 removed
153 unmodified lines154 return ptr155 }156 157 func parseTerms(fuzzy bool, caseMode Case, normalize bool, str string) []termSet {158- str = strings.Replace(str, "\\ ", "\t", -1)158+ str = strings.ReplaceAll(str, "\\ ", "\t")159 tokens := _splitRegex.Split(str, -1)160 sets := []termSet{}161 set := termSet{}162 switchSet := false163 afterBar := false164 for _, token := range tokens {165- typ, inv, text := termFuzzy, false, strings.Replace(token, "\t", " ", -1)165+ typ, inv, text := termFuzzy, false, strings.ReplaceAll(token, "\t", " ")166 lowerText := strings.ToLower(text)167 caseSensitive := caseMode == CaseRespect ||168 caseMode == CaseSmart && text != lowerText169 normalizeTerm := normalize &&245 unmodified linesmodified:src/terminal.go+1 added-1 removed
616 unmodified lines617 return keymap618 }619 620 func trimQuery(query string) []rune {621- return []rune(strings.Replace(query, "\t", " ", -1))621+ return []rune(strings.ReplaceAll(query, "\t", " "))622 }623 624 func mayTriggerPreview(opts *Options) bool {625 if opts.ListenAddr != nil {3780 unmodified lines