Skip to content

Commit

Permalink
Don't ignore whitespace at selection boundaries in highlightSelection…
Browse files Browse the repository at this point in the history
…Matches

FIX: Make `highlightSelectionMatches` include whitespace in the selection in its
matches.

See https://discuss.codemirror.net/t/selectionmatch-ignores-surrounding-whitespace/7697
  • Loading branch information
marijnh committed Jan 15, 2024
1 parent 16a1fc1 commit e766a89
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/selection-match.ts
Expand Up @@ -87,10 +87,10 @@ const matchHighlighter = ViewPlugin.fromClass(class {
if (conf.wholeWords) {
query = state.sliceDoc(range.from, range.to) // TODO: allow and include leading/trailing space?
check = state.charCategorizer(range.head)
if (!(insideWordBoundaries(check, state, range.from, range.to)
&& insideWord(check, state, range.from, range.to))) return Decoration.none
if (!(insideWordBoundaries(check, state, range.from, range.to) &&
insideWord(check, state, range.from, range.to))) return Decoration.none
} else {
query = state.sliceDoc(range.from, range.to).trim()
query = state.sliceDoc(range.from, range.to)
if (!query) return Decoration.none
}
}
Expand Down

0 comments on commit e766a89

Please sign in to comment.