Skip to content

Conversation

@asiloisad
Copy link
Contributor

@asiloisad asiloisad commented Nov 28, 2025

Summary

  • Fix crash in subsequence-provider when autocomplete is triggered in non-workspace editors
  • Add guards for untracked buffers in watchedBuffers map
  • Enables safe use of autocomplete.watchEditor API for custom editors (e.g., watch pane in hydrogen-next)

Problem

The subsequence-provider crashes with Cannot read properties of undefined (reading 'getCursorBufferPosition') when autocomplete is triggered in editors created via atom.workspace.buildTextEditor() that are not part of the workspace.

This happens because:

  1. watchEditor() API registers the editor for autocomplete
  2. subsequence-provider.getSuggestions() tries to get completions from the editor buffer
  3. The buffer is not in watchedBuffers map (only workspace editors are tracked)
  4. this.watchedBuffers.get(buffer) returns undefined
  5. Calling .getCursorBufferPosition() on undefined crashes

Solution

  • Add guard in bufferToSubsequenceMatches to return empty results for untracked buffers
  • Filter buffers in getSuggestions to only include those in watchedBuffers
  • Add null check in subsequenceMatchToType for safety

Test plan

  • Verified fix prevents crash when using watch pane autocomplete in hydrogen-next
  • Existing autocomplete functionality should work unchanged

#1224

@savetheclocktower
Copy link
Contributor

You've opened this against master, but you applied the fix against PulsarNext.

Can you check out a new branch from master, cherry-pick your commits onto that, and then force-push to this branch (or open a new PR)?

The subsequence-provider crashes when autocomplete is triggered in editors
that are not part of the workspace (e.g., watch pane editors in hydrogen-next).
This happens because the editor buffer is not tracked in watchedBuffers.

Changes:
- Add guard in bufferToSubsequenceMatches to return empty results for
  untracked buffers instead of crashing
- Filter buffers in getSuggestions to only include those in watchedBuffers
- Add null check in subsequenceMatchToType for safety

Fixes crashes when using autocomplete.watchEditor API with non-workspace
editors.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@asiloisad asiloisad force-pushed the fix/autocomplete-non-workspace-editors branch from 17eeedb to 09c9fda Compare November 28, 2025 03:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants