Skip to content

Commit a2620d1

Browse files
authored
Merge pull request #3914 from matthias314/m3/fix-issue-3700
quick fix for #3700
2 parents bc5e59c + 560bfcf commit a2620d1

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

internal/action/actions.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,8 +1144,7 @@ func (h *BufPane) find(useRegex bool) bool {
11441144
match, found, err := h.Buf.FindNext(resp, h.Buf.Start(), h.Buf.End(), h.searchOrig, true, useRegex)
11451145
if err != nil {
11461146
InfoBar.Error(err)
1147-
}
1148-
if found {
1147+
} else if found {
11491148
h.Cursor.SetSelectionStart(match[0])
11501149
h.Cursor.SetSelectionEnd(match[1])
11511150
h.Cursor.OrigSelection[0] = h.Cursor.CurSelection[0]

internal/buffer/search.go

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,21 @@ func findLineParams(b *Buffer, start, end Loc, i int, r *regexp.Regexp) ([]byte,
4141
}
4242
}
4343

44-
if padMode == padStart {
45-
r = regexp.MustCompile(".(?:" + r.String() + ")")
46-
} else if padMode == padEnd {
47-
r = regexp.MustCompile("(?:" + r.String() + ").")
48-
} else if padMode == padStart|padEnd {
49-
r = regexp.MustCompile(".(?:" + r.String() + ").")
44+
if padMode != 0 {
45+
re, err := regexp.Compile(r.String() + `\E`)
46+
if err == nil {
47+
// r contains \Q without closing \E
48+
r = re
49+
}
50+
51+
if padMode == padStart {
52+
r = regexp.MustCompile(".(?:" + r.String() + ")")
53+
} else if padMode == padEnd {
54+
r = regexp.MustCompile("(?:" + r.String() + ").")
55+
} else {
56+
// padMode == padStart|padEnd
57+
r = regexp.MustCompile(".(?:" + r.String() + ").")
58+
}
5059
}
5160

5261
return l, charpos, padMode, r

0 commit comments

Comments
 (0)