Skip to content

Auto open diff editor on Refactor Preview #159283

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

marrej
Copy link
Contributor

@marrej marrej commented Aug 26, 2022

Auto opens the Diff Editor when Refactor Preview panel is displayed.

The opening is initiated when the BulkEditPane is created -> when Tree with Edits are populated, by passing the current input into the this._openEditorOnFirstApplicableEdit. This function retrieves either the first checked edit (TextEditElement), if there is any, or the first FileElement if there is none checked.

Assuming that the refactor preview opens only if there is needsConfirmation flag set on at least one WorkspaceEdit, but the edits that require confirmation are not checked by default, so they would not be visible in the opened Diff Editor, it makes more sense to try to open the edit that is checked/visible.
Only if all edits would require confirmation, then the first file would be opened.

The Diff editor should automatically reopen on subsequent reopening of the Refactor Preview panel, if it is not already in view. onDidFocus makes sure that if the _activeEditor exists, and is not visible would be reopened.
To allow this functionality to work for both Editors that can open from BulkEdits, group has been added as well to the deletion editor.
Both _editorService.openEditor() in _openElementAsEditor() have been awaited, so their reference can be used to reopen the DiffEditor.

fixes #158408
fixes #159327

The opening is initiated when the BulkEditPane is created -> when Tree with Edits are populated, by passing the current input into the `this._openEditorOnFirstApplicableEdit`. This function retrieves either the first checked edit (TextEditElement), if there is any, or the first FileElement if there is none checked.

Assuming that the refactor preview opens only if there is `needsConfirmation` flag set on at least one `WorkspaceEdit`, but the edits that require confirmation are not checked by default, so they would not be visible in the opened Diff Editor, it makes more sense to try to open the edit that is checked/visible.
Only if all edits would require confirmation, then the first file would be opened.

The Diff editor should automatically reopen on subsequent reopening of the **Refactor Preview** panel, if it is not already in view. `onDidFocus` makes sure that if the `_activeEditor` exists, and is not visible would be reopened.
To allow this functionality to work for both Editors that can open from BulkEdits, group has been added as well to the deletion editor.
Both `_editorService.openEditor()` in `_openElementAsEditor()` have been `awaited`, so their reference can be used to reopen the DiffEditor.
@laurentlb
Copy link
Contributor

fyi, this is the 1st proposed change described in #156886 (comment) (cc @mjbvz and @justschen).

@laurentlb
Copy link
Contributor

fyi, @isidorn

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.

Auto open Diff Editor when Refactor Preview is opened Automatically show diff editor in refactor preview
3 participants