Optional
filter: SearchFilterFunction that can filter away matches based on their position.
The filter can be changed later using the setFilter
method.
Optional
includeHyphens: ((cursorPosition) => boolean)A function returning whether or not hyphens should be included in the search. For languages that don't commonly use hyphens as an operator (such as CSS), it makes sense to return true. If this parameter is omitted, hyphens are not included.
The CSS-selector .word-matches span
can be used to style the matches.
This filters away all words that start inside a string, comment or keyword or regex token. Different filter functions should be chosen based on the language.
const selector = ".string, .comment, .keyword, .regex"
const filter = start => !getClosestToken(editor, selector, 0, 0, start)
const includeHyphens = position => getLanguage(editor, position) == "css"
editor.addExtensions(
highlightCurrentWord(filter, includeHyphens)
)
Generated using TypeDoc
Extension that highlights all instances of the word the cursor is on if there's no selection.