Skip to content

Reveal the edited file after applying a code action - #4566

Open
robstryker wants to merge 1 commit into
redhat-developer:mainfrom
robstryker:issue765
Open

robstryker wants to merge 1 commit into
redhat-developer:mainfrom
robstryker:issue765

Conversation

@robstryker

Copy link
Copy Markdown
Contributor

When a quick fix edits a document other than the active one (e.g. "Create method 'call()' in type 'Foo'"), VS Code applies the edit but leaves the active editor alone. Attach a java.reveal.edit command to code actions that carry an edit so the changed file is shown and the first change is revealed. The target is taken from the raw LSP edit since WorkspaceEdit.entries() does not include snippet edits, and any command the action already has is run first.

Also move revealWorkspaceEdit next to applyWorkspaceEdit, make it open the document with showTextDocument instead of revealing in whichever editor is active, and use it for java.apply.workspaceEdit.

Method revealWorkspaceEdit was moved between files to avoid a circular dependency.

Fixes #765

When a quick fix edits a document other than the active one (e.g. "Create
method 'call()' in type 'Foo'"), VS Code applies the edit but leaves the
active editor alone. Attach a java.reveal.edit command to code actions
that carry an edit so the changed file is shown and the first change is
revealed. The target is taken from the raw LSP edit since
WorkspaceEdit.entries() does not include snippet edits, and any command
the action already has is run first.

Also move revealWorkspaceEdit next to applyWorkspaceEdit, make it open the
document with showTextDocument instead of revealing in whichever editor
is active, and use it for java.apply.workspaceEdit.

Fixes redhat-developer#765

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: Rob Stryker <rob@oxbeef.net>
@robstryker
robstryker requested a review from MeherSru October 30, 2026 18:37
@robstryker

Copy link
Copy Markdown
Contributor Author

@MeherSru Please test and review this PR. Thanks.

See #765 for the bug report.

This branch has not been deployed

No deployments
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.

The editor can't switch to the new created method

2 participants