Skip to content

Improve workflow for applying/previewing fixes #156886

Open

Description

WorkspaceEdit is a type in the VS Code API to apply changes to the code. It can be used from a Code Action or from any command (using the applyEdit function).

The current implementation works well for applying local or obvious code transformations. This is often the case with fixes suggested by linters or mechanical code transformations.

As IDEs and related tools become more advanced, they should be able to suggest more complex code transformations. The transformations may come from a human (e.g. during a code review) or a tool. In that case, it is important to let the developer review the change before applying it:

  • The suggested change is not always correct and can require special attention.
  • The changes may be complex, modify many locations in a file or in multiple files. The user may accept a subset of the suggested changes.

With our UX team at Google, we have explored solutions to improve the current workflow and give more power to extension developers. As we are using more and more machine learning, we believe it's important to gather additional data (was the suggested change useful?).

Our summary is in this presentation:
Apply fixes proposal

Of course we can file separate issues to discuss the specific points, but I first wanted to share the big picture.

cc Alberto Elizondo (@albertelo)

Activity

  1. albertelo commented on Aug 2, 2022

    @albertelo

    Adding David Dossett (@daviddossett) and @misolori who I brought this issue up a month or so ago.

  2. miguelsolorio commented on Aug 2, 2022

    @miguelsolorio
    Contributor

    Would it be possible to paste in the proposed solutions into this issue as opposed to linking to the deck (which is helpful as well)? Just want to ensure we capture this if/when those resources no longer exist.

  3. laurentlb commented on Aug 3, 2022

    @laurentlb
    ContributorAuthor

    Here's the list of proposed changes:

    1. Open the diff view when the Refactor Preview is opened (by default, the UX is confusing)
    2. We want a way to select all the changes by default the user should see the changes in the refactor, without having to manually select them all one by one). Unfortunately I expect we need a new API for this (if we want to preserve backward compatibility).
    3. When there are multiple types of changes, have a checkbox in front of the type description (to easily enable/disable the corresponding set of changes)
    4. Have a way to say that some types of changes are mutually exclusive (e.g. a tool provides two solutions for the same problem, and the user can pick only one)
    5. When navigating the changes, the panel should have the focus (so that Space can quickly enable/disable the change I am viewing)
    6. Provide a way for the user to give feedback on a refactoring (e.g. thumb up / thumb down). This is probably too specific; a better solution could be to let the extension developer register their own custom actions.

    And a small UX nit.: update the css of the Discard button, it shouldn't be a primary action. Rename Apply to Apply changes (to clarify it will apply all the selected changes).

  4. albertelo commented on Aug 3, 2022

    @albertelo

    Apply fixes proposal.pdf
    I've converted the deck into a pdf. Some images look quite grainy because they are gifs in the deck - I'll upload those separately

  5. justschen commented on Aug 3, 2022

    @justschen
    Collaborator

    @misolori I've actually been exploring this idea as part of the Code Actions Widget, as well as when I added the refactoring preview (#151140), although it would only apply to refactoring and edit selections from the widget.

    At the moment, I'm only looking at Code Actions in particular, which include Quick Fixes, Source Actions, and Refactorings (ie. Extract to inner function with arrow, Surround with Async, Change spelling..., Fix all detected spelling errors, Add all missing imports, etc). When hitting Ctrl + Enter on a selected Code Action, it would open the bulk editor Refactor Preview pane but was also considering opening the Refactor Preview editor (diff view) by default.

    image 8
    (When mouse hovers over)

    Not sure if this is a step towards what you're looking for, but might be an interesting thing to also check out!

  6. added
    under-discussion
    on Aug 15, 2022
  7. albertelo commented on Aug 16, 2022

    @albertelo

    pinging the thread for updates or if there's something you need from our side that we might have missed in our first messages - thank you!

  8. added this to the Backlog milestone on Dec 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

under-discussionworkspace-edit

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions