[command-palette] Guard against failure to highlight a match

This commit is contained in:
Andrew Dupont 2024-02-08 19:43:35 -08:00
parent d1bb4c24a2
commit 2c5be1eda9

View File

@ -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;
let matchIndexes = matches ? (matches.matchIndexes ?? []) : []
matchIndexes.forEach(matchIndex => {
const unmatched = text.substring(lastIndex, matchIndex)
if (unmatched) {
if (matchedChars.length > 0) {