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

code actions on save for autosave afterDelay #221785

Merged
merged 6 commits into from
Jul 22, 2024

Conversation

justschen
Copy link
Contributor

@justschen justschen commented Jul 16, 2024

ref: #200881

This will trigger code actions for organize imports when the following conditions are applied:

  • file auto save is set to afterDelay
  • editor code actions (source.organizeImports) is set to always
  • setting: editor.codeActions.triggerOnFocusChange is true (default is false)

note: will still be triggered when afterDelay is on and we manually trigger a safe (same as current behavior)

TLDR: we match the behavior of onFocusChange or onWindowChange save styles when code actions are always and our save style is afterDelay

@justschen justschen marked this pull request as ready for review July 18, 2024 21:03
@vscodenpa vscodenpa added this to the July 2024 milestone Jul 18, 2024
@justschen justschen requested a review from mjbvz July 18, 2024 21:06
}

private async triggerCodeActionsCommand() {
if (this.configurationService.getValue<boolean>('editor.codeActions.triggerOnFocusChange') && this.configurationService.getValue<string>('files.autoSave') === 'afterDelay') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there any constants we can use for these setting IDs instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't atm

Comment on lines +52 to +54
'editor.codeActions.triggerOnFocusChange': {
type: 'boolean',
scope: ConfigurationScope.LANGUAGE_OVERRIDABLE,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be restricted?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"value of this configuration will be read only from trusted sources." not entirely sure what this means? our other code actions on save aren't restricted iirc, but unsure if this needs or not

@Tyriar
Copy link
Member

Tyriar commented Jul 19, 2024

Thanks for the updates 👍

@justschen justschen merged commit 3077ca9 into microsoft:main Jul 22, 2024
6 checks passed
@vs-code-engineering vs-code-engineering bot locked and limited conversation to collaborators Sep 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants