Merge pull request #913 from savetheclocktower/fix-command-palette-match-highlighting

[command-palette] Guard against failure to highlight a match
This commit is contained in:
Andrew Dupont 2024-02-09 09:17:46 -08:00 committed by GitHub
commit 732d1d40a6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

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