Skip to content

fix: Exception when selecting text on destroyed component - #285

Merged
kommander merged 5 commits into
anomalyco:mainfrom
veracioux:fix/selection-destroyed-buffer
Nov 19, 2025
Merged

kommander merged 5 commits into
anomalyco:mainfrom
veracioux:fix/selection-destroyed-buffer

Conversation

@veracioux

Copy link
Copy Markdown
Contributor

@veracioux
veracioux requested a review from kommander as a code owner November 9, 2025 00:21
@kommander

Copy link
Copy Markdown
Collaborator

The TextBufferView is a low level API that wraps the FFI bindings and I made the guard throw so it can be caught, instead of causing a segfault when accessing destroyed native structs.

Trying to return something in some methods but not others would be inconsistent and can lead to hard to debug issues, because it hides the actual error.

Renderables are built on top of these lower level apis, which have to deal with destroyed objects. In this case the Text renderable is destroyed, which also destroys the underlying TextBufferView.

IMO the selection logic in renderer.ts needs to make sure it deals with destroyed objects and does not trigger selection methods on destroyed Renderables, as there are and might be more Renderables that handle selection, but do not use a TextBufferView, like the ASCIIFontRenderable for example.

I would try to reproduce this in a test for the renderer selection logic in src/tests and then make sure the logic does not try to update the selection on destroyed Renderables.

@veracioux

Copy link
Copy Markdown
Contributor Author

I see, I'll try to implement it that way.

@veracioux
veracioux requested review from Hona and msmps as code owners November 17, 2025 21:07
@veracioux

Copy link
Copy Markdown
Contributor Author

@kommander Implemented according to your suggestion.

  • Without the fixes, the test fails reproducibly
  • Tested in opencode too, so the downstream issue should be fixed by this as well

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.

bug: selecting text from error toast caused error

2 participants