mirror of
https://github.com/junegunn/fzf.git
synced 2025-11-16 07:13:48 -05:00
refactor: use maps.Copy and maps.Clone (#4518)
Signed-off-by: mickychang9 <mickychang9@outlook.com>
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
package fzf
|
package fzf
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"maps"
|
||||||
"os"
|
"os"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
@@ -225,10 +226,7 @@ func Run(opts *Options) (int, error) {
|
|||||||
}
|
}
|
||||||
patternBuilder := func(runes []rune) *Pattern {
|
patternBuilder := func(runes []rune) *Pattern {
|
||||||
denyMutex.Lock()
|
denyMutex.Lock()
|
||||||
denylistCopy := make(map[int32]struct{})
|
denylistCopy := maps.Clone(denylist)
|
||||||
for k, v := range denylist {
|
|
||||||
denylistCopy[k] = v
|
|
||||||
}
|
|
||||||
denyMutex.Unlock()
|
denyMutex.Unlock()
|
||||||
return BuildPattern(cache, patternCache,
|
return BuildPattern(cache, patternCache,
|
||||||
opts.Fuzzy, opts.FuzzyAlgo, opts.Extended, opts.Case, opts.Normalize, forward, withPos,
|
opts.Fuzzy, opts.FuzzyAlgo, opts.Extended, opts.Case, opts.Normalize, forward, withPos,
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package fzf
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"maps"
|
||||||
"os"
|
"os"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
@@ -2603,9 +2604,7 @@ func parseOptions(index *int, opts *Options, allArgs []string) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
for k, v := range chords {
|
maps.Copy(opts.Expect, chords)
|
||||||
opts.Expect[k] = v
|
|
||||||
}
|
|
||||||
case "--no-expect":
|
case "--no-expect":
|
||||||
opts.Expect = make(map[tui.Event]string)
|
opts.Expect = make(map[tui.Event]string)
|
||||||
case "--enabled", "--no-phony":
|
case "--enabled", "--no-phony":
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"maps"
|
||||||
"math"
|
"math"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
@@ -950,10 +951,7 @@ func NewTerminal(opts *Options, eventBox *util.EventBox, executor *util.Executor
|
|||||||
wordRubout = fmt.Sprintf("%s[^%s]", sep, sep)
|
wordRubout = fmt.Sprintf("%s[^%s]", sep, sep)
|
||||||
wordNext = fmt.Sprintf("[^%s]%s|(.$)", sep, sep)
|
wordNext = fmt.Sprintf("[^%s]%s|(.$)", sep, sep)
|
||||||
}
|
}
|
||||||
keymapCopy := make(map[tui.Event][]*action)
|
keymapCopy := maps.Clone(opts.Keymap)
|
||||||
for key, action := range opts.Keymap {
|
|
||||||
keymapCopy[key] = action
|
|
||||||
}
|
|
||||||
|
|
||||||
t := Terminal{
|
t := Terminal{
|
||||||
initDelay: delay,
|
initDelay: delay,
|
||||||
|
|||||||
Reference in New Issue
Block a user