From 7e771d073b2c6494517338019736f110dda8f19a Mon Sep 17 00:00:00 2001 From: CuteReimu <415551921@qq.com> Date: Sun, 25 Jun 2023 15:18:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=90=9C=E7=B4=A2=E6=97=B6?= =?UTF-8?q?=E6=9C=89=E7=9A=84splits=E4=BC=9A=E5=87=BA=E7=8E=B0=E5=A4=9A?= =?UTF-8?q?=E6=AC=A1=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- autosplits.go | 22 ++++++++++------------ go.mod | 1 + go.sum | 4 ++-- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/autosplits.go b/autosplits.go index ef4d3b1..d9a9c3d 100644 --- a/autosplits.go +++ b/autosplits.go @@ -6,6 +6,7 @@ import ( "errors" "github.com/lxn/walk" . "github.com/lxn/walk/declarative" + "golang.org/x/exp/slices" "io" "path" "regexp" @@ -26,11 +27,10 @@ func initSplitsSearchDict(content string) { for i := 0; i < len(rs); i++ { for j := i + 1; j <= len(rs); j++ { s := string(rs[i:j]) - v, ok := splitsSearchDict[s] - if !ok { - v = nil + v := splitsSearchDict[s] + if !slices.Contains(v, content) { + splitsSearchDict[s] = append(v, content) } - splitsSearchDict[s] = append(v, content) } } } @@ -322,16 +322,14 @@ func onSearchSplitId(initAll bool, line *lineData) { return } if len(s) > 0 { - for _, text := range model.items { - if text == s { - if line.name != nil { - err := line.name.SetText(dropBrackets(text)) - if err != nil { - walk.MsgBox(mainWindow, "错误", err.Error(), walk.MsgBoxIconError) - } + if _, ok := splitsDict[s]; ok { + if line.name != nil { + err := line.name.SetText(dropBrackets(s)) + if err != nil { + walk.MsgBox(mainWindow, "错误", err.Error(), walk.MsgBoxIconError) } - return } + return } v, ok := splitsSearchDict[s] if ok && len(v) > 0 { diff --git a/go.mod b/go.mod index fd1805d..bb31fd5 100644 --- a/go.mod +++ b/go.mod @@ -6,6 +6,7 @@ require ( github.com/dlclark/regexp2 v1.10.0 github.com/lxn/walk v0.0.0-20210112085537-c389da54e794 github.com/lxn/win v0.0.0-20210218163916-a377121e959e + golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 ) require ( diff --git a/go.sum b/go.sum index c5c36ad..dc211c8 100644 --- a/go.sum +++ b/go.sum @@ -4,9 +4,9 @@ github.com/lxn/walk v0.0.0-20210112085537-c389da54e794 h1:NVRJ0Uy0SOFcXSKLsS65Om github.com/lxn/walk v0.0.0-20210112085537-c389da54e794/go.mod h1:E23UucZGqpuUANJooIbHWCufXvOcT6E7Stq81gU+CSQ= github.com/lxn/win v0.0.0-20210218163916-a377121e959e h1:H+t6A/QJMbhCSEH5rAuRxh+CtW96g0Or0Fxa9IKr4uc= github.com/lxn/win v0.0.0-20210218163916-a377121e959e/go.mod h1:KxxjdtRkfNoYDCUP5ryK7XJJNTnpC8atvtmTheChOtk= +golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 h1:k/i9J1pBpvlfR+9QsetwPyERsqu1GIbi967PQMq3Ivc= +golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w= golang.org/x/sys v0.0.0-20201018230417-eeed37f84f13/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU= -golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.9.0 h1:KS/R3tvhPqvJvwcKfnBHJwwthS11LRhmM5D59eEXa0s= golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= gopkg.in/Knetic/govaluate.v3 v3.0.0 h1:18mUyIt4ZlRlFZAAfVetz4/rzlJs9yhN+U02F4u1AOc=