Skip to content
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

Test: Refactoring Preview Code Action #153392

Closed
3 tasks done
justschen opened this issue Jun 27, 2022 · 0 comments
Closed
3 tasks done

Test: Refactoring Preview Code Action #153392

justschen opened this issue Jun 27, 2022 · 0 comments

Comments

@justschen
Copy link
Contributor

justschen commented Jun 27, 2022

Refs #151140

Complexity: 2

Create Issue


Set up:

In the Command Palette, there is a new action called Refactor with Preview... In order to run this, highlight some code, select the option by searching and running Refactor with Preview... and it should open up the refactoring menu with some options. Click on any of the options and the Refactor Preview (bulk editor) should open up in the workbench. Clicking on the refactorings available in the Refactor Preview pane will open up a side-by-side view in the editor. Edits must be made in a saved file, or the side-by-side will not show up.

Things to keep in mind: Currently the UX is not excellent - we're simply using the refactor preview from the bulk editor, so the preview pane itself might get incredibly bloated with ↩️ (new line indicators) and lots of red highlighted + crossed out code. The core refactoring results should not change.

After clicking on the option from refactoring menu:
image

After clicking in the refactoring preview pane:
image

Testing:

  1. Highlight some code you want to refactor.
  2. Run the command Refactor with Preview from the command palette.
  3. A menu will pop up with refactoring options - click on a valid highlighted option.
  4. Clicking on any of the menu options will open up the workbench and the refactoring preview pane, similar to Rename Symbol.
  5. Note that all highlighted lines will be checkmarked, but you have the option to uncheck certain lines and apply the refactoring of only that specific line.
  6. Click on the lines of edited code in the preview pane to pull up the preview in the editor.

Recording 2022-06-27 at 14 58 02

  1. Apply the refactoring preview - depending on what kind of refactoring was chosen. An additional prompt about renaming the extracted function may be triggered as well.
  2. CTRL + Z and highlight the same bit of code. Run Refactor and the same type of refactoring.
  3. Ensure that the two versions of refactoring, with or without preview, have the same end refactored results.

Some Questions:

  • Since the bulk edit pane was intended for smaller changes with a larger quantity of files, it may not precisely fit the kind of refactoring we want. Does this version of refactoring help, and are there better ways to indicate differences when refactoring?
  • Is there a better flow to get to the refactoring preview screen (ie. having the Refactoring with Preview in the context menu, or having fly-outs instead of in the workbench, etc).
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants