mirror of
https://github.com/junegunn/fzf.git
synced 2025-11-15 06:43:47 -05:00
chore: use strings.ReplaceAll (#3801)
This commit is contained in:
@@ -342,8 +342,8 @@ func TestAnsiCodeStringConversion(t *testing.T) {
|
|||||||
state := interpretCode(code, prevState)
|
state := interpretCode(code, prevState)
|
||||||
if expected != state.ToString() {
|
if expected != state.ToString() {
|
||||||
t.Errorf("expected: %s, actual: %s",
|
t.Errorf("expected: %s, actual: %s",
|
||||||
strings.Replace(expected, "\x1b[", "\\x1b[", -1),
|
strings.ReplaceAll(expected, "\x1b[", "\\x1b["),
|
||||||
strings.Replace(state.ToString(), "\x1b[", "\\x1b[", -1))
|
strings.ReplaceAll(state.ToString(), "\x1b[", "\\x1b["))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assert("\x1b[m", nil, "")
|
assert("\x1b[m", nil, "")
|
||||||
|
|||||||
@@ -554,7 +554,7 @@ func splitNth(str string) ([]Range, error) {
|
|||||||
|
|
||||||
func delimiterRegexp(str string) Delimiter {
|
func delimiterRegexp(str string) Delimiter {
|
||||||
// Special handling of \t
|
// 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
|
// 1. Pattern does not contain any special character
|
||||||
if regexp.QuoteMeta(str) == str {
|
if regexp.QuoteMeta(str) == str {
|
||||||
@@ -1132,9 +1132,9 @@ Loop:
|
|||||||
masked += strings.Repeat(" ", loc[1])
|
masked += strings.Repeat(" ", loc[1])
|
||||||
action = action[loc[1]:]
|
action = action[loc[1]:]
|
||||||
}
|
}
|
||||||
masked = strings.Replace(masked, "::", string([]rune{escapedColon, ':'}), -1)
|
masked = strings.ReplaceAll(masked, "::", string([]rune{escapedColon, ':'}))
|
||||||
masked = strings.Replace(masked, ",:", string([]rune{escapedComma, ':'}), -1)
|
masked = strings.ReplaceAll(masked, ",:", string([]rune{escapedComma, ':'}))
|
||||||
masked = strings.Replace(masked, "+:", string([]rune{escapedPlus, ':'}), -1)
|
masked = strings.ReplaceAll(masked, "+:", string([]rune{escapedPlus, ':'}))
|
||||||
return masked
|
return masked
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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 {
|
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)
|
tokens := _splitRegex.Split(str, -1)
|
||||||
sets := []termSet{}
|
sets := []termSet{}
|
||||||
set := termSet{}
|
set := termSet{}
|
||||||
switchSet := false
|
switchSet := false
|
||||||
afterBar := false
|
afterBar := false
|
||||||
for _, token := range tokens {
|
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)
|
lowerText := strings.ToLower(text)
|
||||||
caseSensitive := caseMode == CaseRespect ||
|
caseSensitive := caseMode == CaseRespect ||
|
||||||
caseMode == CaseSmart && text != lowerText
|
caseMode == CaseSmart && text != lowerText
|
||||||
|
|||||||
@@ -618,7 +618,7 @@ func defaultKeymap() map[tui.Event][]*action {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func trimQuery(query string) []rune {
|
func trimQuery(query string) []rune {
|
||||||
return []rune(strings.Replace(query, "\t", " ", -1))
|
return []rune(strings.ReplaceAll(query, "\t", " "))
|
||||||
}
|
}
|
||||||
|
|
||||||
func mayTriggerPreview(opts *Options) bool {
|
func mayTriggerPreview(opts *Options) bool {
|
||||||
|
|||||||
@@ -1025,7 +1025,7 @@ func (w *LightWindow) Print(text string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func cleanse(str string) 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) {
|
func (w *LightWindow) CPrint(pair ColorPair, text string) {
|
||||||
|
|||||||
@@ -157,10 +157,10 @@ func (x *Executor) QuoteEntry(entry string) string {
|
|||||||
*/
|
*/
|
||||||
return escapeArg(entry)
|
return escapeArg(entry)
|
||||||
case shellTypePowerShell:
|
case shellTypePowerShell:
|
||||||
escaped := strings.Replace(entry, `"`, `\"`, -1)
|
escaped := strings.ReplaceAll(entry, `"`, `\"`)
|
||||||
return "'" + strings.Replace(escaped, "'", "''", -1) + "'"
|
return "'" + strings.ReplaceAll(escaped, "'", "''") + "'"
|
||||||
default:
|
default:
|
||||||
return "'" + strings.Replace(entry, "'", "'\\''", -1) + "'"
|
return "'" + strings.ReplaceAll(entry, "'", "'\\''") + "'"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user