pulsar-edit / pulsar

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

Error thrown by autocomplete while typing #1065

Open jboilesen opened 4 months ago

jboilesen commented 4 months ago

Thanks in advance for your bug report!

What happened?

I was simply writing code when autocomplete throw this error.

Pulsar version

1.119.2024071703 x64

Which OS does this happen on?

🐧 Debian based (Linux Mint, Ubuntu, etc.)

OS details

Debian Bookworm

Which CPU architecture are you running this on?

x86_64/AMD64

What steps are needed to reproduce this?

Sincerely, I am not sure how to reproduce this issue.

I was typing in a big file (4000+ lines) in a big project (3000+ files) and autocomplete thrown this error.

Additional Information:

Versions

Pulsar: 1.119.2024071703 x64 Electron: 12.2.3 OS: Debian GNU/Linux Thrown From: Pulsar Core

Stack Trace

Uncaught TypeError: Cannot read property 'map' of null

At /opt/Pulsar/resources/app.asar/node_modules/text-buffer/lib/text-buffer.js:1323

TypeError: Cannot read property 'map' of null
    at LanguageLayer.getOrParseTree (/app.asar/src/wasm-tree-sitter-language-mode.js:4133:39)
    at WASMTreeSitterLanguageMode.suggestedIndentForEditedBufferRow (/app.asar/src/wasm-tree-sitter-language-mode.js:1909:39)
    at TextEditor.autoDecreaseIndentForBufferRow (/app.asar/src/text-editor.js:5724:36)
    at Selection.insertText (/app.asar/src/selection.js:579:19)
    at /app.asar/src/text-editor.js:1748:31
    at /app.asar/src/text-editor.js:1801:33
    at Array.map (<anonymous>)
    at /app.asar/src/text-editor.js:1800:60
    at TextBuffer.transact (/app.asar/node_modules/text-buffer/lib/text-buffer.js:1320:16)
    at TextEditor.transact (/app.asar/src/text-editor.js:2467:24)
    at /app.asar/src/text-editor.js:1799:19
    at TextEditor.mergeSelections (/app.asar/src/text-editor.js:4053:20)
    at TextEditor.mergeIntersectingSelections (/app.asar/src/text-editor.js:4015:10)
    at TextEditor.mutateSelectedText (/app.asar/src/text-editor.js:1798:17)
    at TextEditor.insertText (/app.asar/src/text-editor.js:1747:25)
    at /app.asar/node_modules/underscore-plus/lib/underscore-plus.js:77:27)
    at TextEditorComponent.didTextInput (/app.asar/src/text-editor-component.js:1845:24)

Commands

     -1:53.8.0 editor:newline (input.hidden-input)
     -1:53.6.0 core:backspace (input.hidden-input)
     -1:51.3.0 core:save (input.hidden-input)
     -1:46.1.0 autocomplete-plus:cancel (input.hidden-input)
     -1:37.4.0 core:backspace (input.hidden-input)
  4x -1:36.6.0 core:save (input.hidden-input)
  3x -1:21.5.0 core:backspace (input.hidden-input)
  5x -1:01.6.0 core:save (input.hidden-input)
     -0:51.7.0 core:move-left (input.hidden-input)
  4x -0:50 core:save (input.hidden-input)
     -0:45.7.0 core:move-right (input.hidden-input)
     -0:44.3.0 core:backspace (input.hidden-input)
     -0:43 core:save (input.hidden-input)
     -0:40.8.0 core:move-left (input.hidden-input)
  4x -0:39 core:save (input.hidden-input)
     -0:27.9.0 core:delete (input.hidden-input)

Non-Core Packages

git-plus 8.7.1 
platformio-ide-terminal 2.10.1 
savetheclocktower commented 4 months ago

Thanks for the report. Can you tell me what sort of file this was? It looks like this was an “injection” scenario — one language embedded in another — so I'm curious to know which language might have the bug here.

jboilesen commented 4 months ago

It happened in a pure .php file with only PHP code (but the project also has HTML, CSS and JS files).

savetheclocktower commented 4 months ago

Strangely, that counts because of the way that the PHP grammar is architected.

I see the bug here (assuming something that may return null is an array without checking it), but I don't yet understand why it happens. Still, I should at least make it so that it doesn't throw an exception.

I'm glad that it's sporadic instead of something that happens all the time. Still, if you figure out reliable reproduction steps, please let me know. Thanks!