Skip to content

Commit

Permalink
修复搜索时有的splits会出现多次的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
CuteReimu committed Jun 25, 2023
1 parent 680547f commit 7e771d0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
22 changes: 10 additions & 12 deletions autosplits.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"errors"
"github.com/lxn/walk"
. "github.com/lxn/walk/declarative"
"golang.org/x/exp/slices"
"io"
"path"
"regexp"
Expand All @@ -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)
}
}
}
Expand Down Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down

0 comments on commit 7e771d0

Please sign in to comment.