pulsar-edit / pulsar

A Community-led Hyper-Hackable Text Editor
https://pulsar-edit.dev
Other
3.33k stars 140 forks source link

"Uncaught TypeError: Cannot read property 'matchIndexes' of undefined" in command-palette #911

Closed jmanuel1 closed 9 months ago

jmanuel1 commented 9 months ago

Thanks in advance for your bug report!

What happened?

Inputting certain terms into the command palette crashes it and makes it unusable.

Pulsar version

1.113.0

Which OS does this happen on?

🪟 Windows

OS details

Windows 11

Which CPU architecture are you running this on?

x86_64/AMD64

What steps are needed to reproduce this?

Reproduction steps:

  1. Install atom-typescript
  2. Activate the typescript package (Typescript: Activate)
  3. Open the command palette
  4. Start typing "typescript"

An error will be thrown with a stack trace like:

C:\Users\jamai\AppData\Local\Programs\Pulsar\resources\app.asar\node_modules\command-palette\lib\command-palette-view.js:139

TypeError: Cannot read property 'matchIndexes' of undefined
    at CommandPaletteView.highlightMatchesInElement (command-palette-view.js:139:13)
    at CommandPaletteView.createDescription (command-palette-view.js:209:10)
    at Object.elementForItem (command-palette-view.js:51:42)
    at C:\Users\jamai\AppData\Local\Programs\Pulsar\resources\app.asar\node_modules\bookmarks\node_modules\atom-select-list\src\select-list-view.js:219:31
    at Array.map (<anonymous>)
    at SelectListView.renderItems (C:\Users\jamai\AppData\Local\Programs\Pulsar\resources\app.asar\node_modules\bookmarks\node_modules\atom-select-list\src\select-list-view.js:215:35)
    at SelectListView.render (C:\Users\jamai\AppData\Local\Programs\Pulsar\resources\app.asar\node_modules\bookmarks\node_modules\atom-select-list\src\select-list-view.js:199:12)
    at updateSync (C:\Users\jamai\AppData\Local\Programs\Pulsar\resources\app.asar\node_modules\bookmarks\node_modules\etch\lib\component-helpers.js:107:34)
    at C:\Users\jamai\AppData\Local\Programs\Pulsar\resources\app.asar\node_modules\bookmarks\node_modules\etch\lib\component-helpers.js:72:7
    at DefaultScheduler.performUpdates (C:\Users\jamai\AppData\Local\Programs\Pulsar\resources\app.asar\node_modules\etch\lib\default-scheduler.js:48:34)

The palette will no longer accept keystrokes, and once you close it, you won't be able to open it again without restarting Pulsar.

Additional Information:

jmanuel1 commented 9 months ago

I think this is definitely a Pulsar bug. The command palette scores commands by the total match score of the display name, and description. Which means the description might not match with the query at all. But, when rendering the results, highlightMatchesInElement is called with the command description and the query in createDescription, and highlightMatchesInElement assumes that the description will fuzzy match the query. But it might not, in which case atom.ui.fuzzyMatcher.match returns undefined.

The reason why the typescript package is involved is that the typescript:build command has "Compile all files in project related to current active text editor" as a description, which doesn't contain "typescript."

savetheclocktower commented 9 months ago

Thanks a lot for investigating this! I'll see if I can get to it tomorrow or Friday.

mauricioszabo commented 9 months ago

Thanks a lot for investigating this, @savetheclocktower. A subtle bug and a devops issue in this single issue, but also an easy approve for the fix (for now - I agree that we need to fix that on fuzzaldrin, but well, C++ code being converted to JS is always harder to fix).