From 2c5be1eda9e5ea1d938f2b258b817bdc4537c41f Mon Sep 17 00:00:00 2001 From: Andrew Dupont Date: Thu, 8 Feb 2024 19:43:35 -0800 Subject: [PATCH 1/2] [command-palette] Guard against failure to highlight a match --- packages/command-palette/lib/command-palette-view.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/command-palette/lib/command-palette-view.js b/packages/command-palette/lib/command-palette-view.js index fdc46f9a4..c53843227 100644 --- a/packages/command-palette/lib/command-palette-view.js +++ b/packages/command-palette/lib/command-palette-view.js @@ -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) { From 7dbbd7afdaf5907d3a233bc4df3f165be175b122 Mon Sep 17 00:00:00 2001 From: Andrew Dupont Date: Fri, 9 Feb 2024 09:17:25 -0800 Subject: [PATCH 2/2] Update packages/command-palette/lib/command-palette-view.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: MaurĂ­cio Szabo --- packages/command-palette/lib/command-palette-view.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/command-palette/lib/command-palette-view.js b/packages/command-palette/lib/command-palette-view.js index c53843227..40703d148 100644 --- a/packages/command-palette/lib/command-palette-view.js +++ b/packages/command-palette/lib/command-palette-view.js @@ -136,7 +136,7 @@ export default class CommandPaletteView { const matches = atom.ui.fuzzyMatcher.match(text, query, {recordMatchIndexes: true}) let matchedChars = [] let lastIndex = 0; - let matchIndexes = matches ? (matches.matchIndexes ?? []) : [] + const matchIndexes = matches ? (matches.matchIndexes ?? []) : [] matchIndexes.forEach(matchIndex => { const unmatched = text.substring(lastIndex, matchIndex) if (unmatched) {