Skip to content

Commit 6633380

Browse files
committed
Fix matching highlight search getting triggered constantly with reverse selections
1 parent 3b8875f commit 6633380

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

modules/search_component.nim

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -180,17 +180,18 @@ when implModule:
180180
if content.len > self.matchingWordHiglightSettings.maxFileSize.get():
181181
return
182182

183-
var oldSelection = edit.selection.normalized
184-
if oldSelection.b.row.int - oldSelection.a.row.int > self.matchingWordHiglightSettings.maxSelectionLines.get():
183+
let oldSelection = edit.selection
184+
var selectionNorm = edit.selection.normalized
185+
if selectionNorm.b.row.int - selectionNorm.a.row.int > self.matchingWordHiglightSettings.maxSelectionLines.get():
185186
return
186187

187-
oldSelection = content.clampOnLine(oldSelection)
188+
selectionNorm = content.clampOnLine(selectionNorm)
188189

189-
let (selection, inclusive, addWordBoundary) = if oldSelection.isEmpty:
190-
var s = moves.applyMove(oldSelection.b...oldSelection.b, "(vim.word)", includeEol=false).normalized
190+
let (selection, inclusive, addWordBoundary) = if selectionNorm.isEmpty:
191+
var s = moves.applyMove(selectionNorm.b...selectionNorm.b, "(vim.word)", includeEol=false).normalized
191192
const AlphaNumeric = {'A'..'Z', 'a'..'z', '0'..'9', '_'}
192193
if content.charAt(s.a) notin AlphaNumeric:
193-
let prev = point(oldSelection.b.row, oldSelection.b.column - 1)
194+
let prev = point(selectionNorm.b.row, selectionNorm.b.column - 1)
194195
if s.a.column > 0 and content.charAt(prev) in AlphaNumeric:
195196
s = moves.applyMove(prev...prev, "(vim.word)", includeEol=false).normalized
196197
else:
@@ -201,7 +202,7 @@ when implModule:
201202
return
202203
(s, false, true)
203204
else:
204-
(oldSelection.normalized, self.useInclusiveSelections, false)
205+
(selectionNorm.normalized, self.useInclusiveSelections, false)
205206

206207
let startByte = content.pointToOffset(selection.a)
207208
let endByte = content.pointToOffset(selection.b)

0 commit comments

Comments
 (0)