[autocomplete-plus] the `watchEditor` API is broken
Thanks in advance for your bug report!
- [x] Have you reproduced issue in safe mode?
- [x] Have you used the debugging guide to try to resolve the issue?
- [x] Have you checked our FAQs to make sure your question isn't answered there?
- [x] Have you checked to make sure your issue does not already exist?
- [x] Have you checked you are on the latest release of Pulsar?
What happened?
A package autocomplete-plus offers an API called watchEditor to get autocomplete function to external editors, e.g.
-
find-and-replace->find-container -
hydrogen-next->watch-input - and more...
Stack Trace
Uncaught TypeError: Cannot read property 'getCursorBufferPosition' of undefined
At C:\Program Files\Pulsar\resources\app.asar\node_modules\autocomplete-plus\lib\subsequence-provider.js:136
TypeError: Cannot read property 'getCursorBufferPosition' of undefined
at SubsequenceProvider.bufferToSubsequenceMatches (/app.asar/node_modules/autocomplete-plus/lib/subsequence-provider.js:136:53)
at Array.map (<anonymous>)
at SubsequenceProvider.getSuggestions (/app.asar/node_modules/autocomplete-plus/lib/subsequence-provider.js:258:12)
at /app.asar/node_modules/autocomplete-plus/lib/autocomplete-manager.js:284:52
at Array.forEach (<anonymous>)
at AutocompleteManager.getSuggestionsFromProviders (/app.asar/node_modules/autocomplete-plus/lib/autocomplete-manager.js:255:15)
at AutocompleteManager.findSuggestions (/app.asar/node_modules/autocomplete-plus/lib/autocomplete-manager.js:247:17)
at AutocompleteManager.requestNewSuggestions (/app.asar/node_modules/autocomplete-plus/lib/autocomplete-manager.js:702:12)
at AutocompleteManager.showOrHideSuggestionListForBufferChanges (/app.asar/node_modules/autocomplete-plus/lib/autocomplete-manager.js:768:12)
at Function.simpleDispatch (/app.asar/node_modules/event-kit/dist/emitter.js:64:14)
at Emitter.emit (/app.asar/node_modules/event-kit/dist/emitter.js:257:28)
at TextBuffer.emitDidChangeTextEvent (/app.asar/node_modules/text-buffer/lib/text-buffer.js:2374:24)
at TextBuffer.transact (/app.asar/node_modules/text-buffer/lib/text-buffer.js:1337:10)
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 TextEditorComponent.didTextInput (/app.asar/src/text-editor-component.js:1845:24)
It look like the problem is SubsequenceProvider expect that all editors are regirestred to atom.workspace, because then it's try to restore editor from buffer.
I see two possible solutions:
- recover editor from buffer in different way (?),
- change
atom.workspace.observeTextEditorstoatom.textEditors.observetogether with this https://github.com/pulsar-edit/pulsar/pull/1190.
Pulsar version
1.124.0
Which OS does this happen on?
🪟 Windows
OS details
10
Which CPU architecture are you running this on?
x86_64/AMD64
What steps are needed to reproduce this?
- Go to settings of
find-and-replacepackage.` - Activate
Autocomplete Search - Open any text editor
- Open find-and-replace window
- Type 3 or more characters (to trigger autocomplete)
Additional Information:
https://github.com/atom/autocomplete-plus/pull/872
The subsequence provider is a barely useful fallback provider used when you don't have something smarter. It just suggests words that have already been typed in the buffer — even less useful when you're in an external editor. If I had my way it wouldn't be enabled at all, so one option would be to disable it for mini editors, or at least have it fail gracefully when it can't find the editor in atom.workspace.
I have dig it more and an issue occurs only if config includeCompletionsFromAllBuffers is set to false.