Skip to content

fix: prevent "TextEditor is closed/disposed" warnings #5956

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

roomote[bot]
Copy link

@roomote roomote bot commented Jul 19, 2025

This PR fixes the issue where "TextEditor is closed/disposed" warnings were being spammed in the logs when Roo Code performs API actions and edits documents.

Problem

The extension was attempting to access TextEditor instances that had already been disposed, causing frequent warning messages (tens per second) in the VS Code output.

Solution

  • Added disposal tracking and checks to DecorationController before calling any TextEditor methods
  • Added try-catch blocks around TextEditor property access to gracefully handle disposed editors
  • Properly dispose decoration controllers in DiffViewProvider when resetting
  • Protected editor access in getEnvironmentDetails.ts and registerCommands.ts
  • Added comprehensive unit tests for disposal handling

Changes

  • Modified DecorationController.ts to track disposal state and check editor validity before operations
  • Updated DiffViewProvider.ts to properly dispose controllers and handle disposed editors
  • Added protection in getEnvironmentDetails.ts for accessing editor document properties
  • Added protection in registerCommands.ts for accessing editor viewColumn property
  • Created comprehensive test suite for DecorationController disposal handling

Testing

  • All existing tests pass
  • New tests added specifically for disposal scenarios
  • Verified that warnings no longer appear when editors are closed during operations

Fixes #5954


Important

Fixes 'TextEditor is closed/disposed' warnings by adding disposal checks and handling in DecorationController and DiffViewProvider, with comprehensive tests added.

  • Behavior:
    • Added disposal tracking and checks in DecorationController to prevent operations on disposed TextEditor instances.
    • Wrapped TextEditor property access in try-catch blocks in DecorationController.ts and DiffViewProvider.ts to handle disposed editors gracefully.
    • Properly dispose of decoration controllers in DiffViewProvider during reset.
    • Added checks in getEnvironmentDetails.ts and registerCommands.ts to protect against accessing properties of disposed editors.
  • Testing:
    • Added comprehensive unit tests in __tests__/DecorationController.spec.ts to cover disposal scenarios.
    • Verified that warnings no longer appear when editors are closed during operations.
  • Misc:
    • Minor logging changes to provide debug information when operations fail due to disposed editors.

This description was created by Ellipsis for 6b68b16. You can customize this summary. It will automatically update as commits are pushed.

- Add disposal tracking and checks to DecorationController
- Add try-catch blocks around TextEditor property access
- Properly dispose decoration controllers in DiffViewProvider
- Add comprehensive tests for disposal handling
- Protect editor access in getEnvironmentDetails and registerCommands

Fixes #5954
@roomote roomote bot requested review from mrubens, cte and jr as code owners July 19, 2025 18:44
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. bug Something isn't working labels Jul 19, 2025
@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Jul 19, 2025
@daniel-lxs
Copy link
Collaborator

Closing in favor of #5958

@daniel-lxs daniel-lxs closed this Jul 21, 2025
@github-project-automation github-project-automation bot moved this from Triage to Done in Roo Code Roadmap Jul 21, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Jul 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. size:L This PR changes 100-499 lines, ignoring generated files.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[warning] TextEditor is closed/disposed spam
3 participants