Skip to content

Move Code Action Constraints  #58387

Closed
Closed
@justschen

Description

@justschen

Acknowledgement

  • I acknowledge that issues using this template may be closed without further explanation at the maintainer's discretion.

Comment

related #56416 and https://github.com/microsoft/TypeScript/pull/57080/files

We had some discussion within the VS Code team regarding the changes @aiday-mar made and how we wanted to make the constraints tighter.

the current sentiment after discussion:

  • when moving or clicking through code (ie, not selecting a range of code), users likely will not want to see the Move to... code actions. however, it should be available to them if they manually select (via Refactor or CmdCtrl + .)
    • this fixes the annoyance of having the lightbulb widget shown virtually everywhere in the file when typing or moving trough code.
  • however, if the cursor is at the top scoping level or on its identifier, we can show the Move to... actions.

Reasoning behind not having the lightbulb be so aggressive in suggesting code actions is that the lightbulb loses value (ie, blue lightbulb means there are fixes, but yellow lightbulb is super general). Even if users don't explicitly hit the lightbulb button, when they see certain changes in the lightbulb, they might hit CmdCtrl + . to trigger the code actions.

when actually selecting a range of code, I believe @aiday-mar had some proposed fixes for the constraints as well, similarly looking at scoping.

In our latest stable release (1.89.0), i added a good amount of telemetry tracking a few things that might help us make a more informed and concrete decision if we want to move forward with this:

  • when the lightbulb is clicked -> which code actions and providers are shown in that code action menu
  • when the code action menu is exited (and the source of the menu was the lightbulb) -> if a code action was selected or if it was just quit out.
  • when code actions are applied -> we can see how often move to... is being used when the source is the lightbulb widget.
  • in insiders only: how often the lightbulb widget shows up when there is only a single code action in that list (ie, only move to file)

currently have a draft PR for our built in extension, but as Matt mentioned, likely would be best to fix here so the behavior is consistent across all editors.

I'll likely take a look at making a PR here, so any help would be appreciated!

Let me know if there are any thoughts on this, if we think it's too drastic, if we want to see more telemetry, etc.

cc. @mjbvz @navya9singh @andrewbranch @aiday-mar

Metadata

Metadata

Assignees

No one assigned

    Labels

    Domain: Refactoringse.g. extract to constant or function, rename symbolSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions