Skip to content

Commit

Permalink
Merge pull request #913 from savetheclocktower/fix-command-palette-ma…
Browse files Browse the repository at this point in the history
…tch-highlighting

[command-palette] Guard against failure to highlight a match
  • Loading branch information
savetheclocktower authored Feb 9, 2024
2 parents d1bb4c2 + 7dbbd7a commit 732d1d4
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/command-palette/lib/command-palette-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,9 @@ export default class CommandPaletteView {
highlightMatchesInElement (text, query, el) {
const matches = atom.ui.fuzzyMatcher.match(text, query, {recordMatchIndexes: true})
let matchedChars = []
let lastIndex = 0
matches.matchIndexes.forEach(matchIndex => {
let lastIndex = 0;
const matchIndexes = matches ? (matches.matchIndexes ?? []) : []
matchIndexes.forEach(matchIndex => {
const unmatched = text.substring(lastIndex, matchIndex)
if (unmatched) {
if (matchedChars.length > 0) {
Expand Down

0 comments on commit 732d1d4

Please sign in to comment.