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

Verify fix/revision to Code Actions on Save #194437

Closed
justschen opened this issue Sep 28, 2023 · 11 comments
Closed

Verify fix/revision to Code Actions on Save #194437

justschen opened this issue Sep 28, 2023 · 11 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug candidate Issue identified as probable candidate for fixing in the next release verified Verification succeeded

Comments

@justschen
Copy link
Contributor

justschen commented Sep 28, 2023

tests #194031 and new changes from #194409. related to #194397

added back old boolean values (since we reverted the changes for migration) in addition to supporting new enum values.

This is for both Code Actions in notebooks and in the editor:

  1. Find notebook.codeActionsOnSave or editor.codeActionsOnSave
  2. test each enum's behavior. note that always currently does not support code actions on auto save after delay. (easiest code actions to test would be source.fixAll and source.organizeImports. other code actions like source.fixAll.eslint and source.removeUnusedImports are supported as well.
  3. test boolean behavior. (true and explicit should be the same, false and never should be the same. there are descriptions about future deprecation and behavior as well!)
@justschen justschen added the bug Issue identified by VS Code Team member as probable bug label Sep 28, 2023
@justschen justschen self-assigned this Sep 28, 2023
@rzhao271 rzhao271 added this to the September 2023 milestone Sep 28, 2023
@justschen justschen added the unreleased Patch has not yet been released in VS Code Insiders label Sep 28, 2023
@bhavyaus
Copy link
Collaborator

Closing this as completed. Waiting on insiders to verify.

@bhavyaus bhavyaus added the verification-needed Verification of issue is requested label Sep 28, 2023
@VSCodeTriageBot VSCodeTriageBot removed the unreleased Patch has not yet been released in VS Code Insiders label Sep 29, 2023
@VSCodeTriageBot
Copy link
Collaborator

Issue marked as unreleased but unable to locate closing commit in issue timeline. You can manually reference a commit by commenting \closedWith someCommitSha, or directly add the insiders-released label if you know this has already been releaased

@VSCodeTriageBot VSCodeTriageBot added the unreleased Patch has not yet been released in VS Code Insiders label Sep 29, 2023
@bhavyaus bhavyaus removed the unreleased Patch has not yet been released in VS Code Insiders label Sep 29, 2023
@justschen justschen changed the title Testing fix/revision to Code Actions on Save Verify fix/revision to Code Actions on Save Sep 29, 2023
@chrmarti chrmarti added the verified Verification succeeded label Sep 29, 2023
@chrmarti
Copy link
Contributor

@justschen For notebooks I see only two choices, is this expected?
image

@justschen
Copy link
Contributor Author

Yep! That's because you already inserted the quotations, so it only gives the string results. When no input or anything has been typed yet, you should get the following on intellisense. Should be the same for editor as well.

Screenshot 2023-09-28 at 11 50 36 PM

@chrmarti chrmarti removed the verified Verification succeeded label Sep 29, 2023
@chrmarti
Copy link
Contributor

Verified for editor code actions. I can't notebook code actions to work. @Yoyokrazy Could you provide steps to use "notebook.codeActionsOnSave" with Python notebooks? (Or some other language that is easy to set up.)

@chrmarti chrmarti added the verification-steps-needed Steps to verify are needed for verification label Sep 29, 2023
@chrmarti
Copy link
Contributor

Got it working with a Github Issue Notebook (thanks @jrieken):

  "notebook.codeActionsOnSave": {
    "notebook.source.normalizeVariableNames":true
  }

true also triggers it on auto save, which seems inconsistent with editor.codeActionsOnSave given that there is no "always" for notebooks and true for editors is the same as "explicit".

Otherwise works as described.

@chrmarti chrmarti removed the verification-steps-needed Steps to verify are needed for verification label Sep 29, 2023
@justschen
Copy link
Contributor Author

@Yoyokrazy suggested change to support backward compatibility:

if (context.reason === SaveReason.AUTO) {
	//saveTrigger = 'always';
	return undefined;
} 

or just remove entirely since it would be under the umbrella with SaveReason.FOCUS_CHANGE and SaveReason.WINDOW_CHANGE) to return undefined and exit early without applying code actions.

atm, this code includes all code actions when the value is true, even when saveTrigger (SAVE_REASON....) is auto.

const includedActions = allCodeActions
	.filter(x => setting[x.value] === saveTrigger || setting[x.value] === true);

@Yoyokrazy
Copy link
Contributor

Thanks for the catch @chrmarti, PR mentioned here addresses this and SaveReason.FOCUS_CHANGE + SaveReason.WINDOW_CHANGE support will be added during debt week to finalize all of this.

@Yoyokrazy Yoyokrazy added the candidate Issue identified as probable candidate for fixing in the next release label Sep 29, 2023
@amunger amunger added the verified Verification succeeded label Sep 29, 2023
@Yoyokrazy Yoyokrazy removed verification-found Issue verification failed verification-needed Verification of issue is requested labels Sep 29, 2023
@dockleryxk
Copy link

@justschen is there any chance of changing the behavior to run the actions in order when using an object, or will that only be for using an array for the setting?

I know the docs currently say to use an array when you need to execute in order, but that limits the actions to "explicit"

@justschen
Copy link
Contributor Author

justschen commented Oct 5, 2023

@dockleryxk Regarding the fixes around #194861, this is something we may look into! atm, as you can see from #194861 (comment), we do explicitly force fixAll to run first, but may change the schema to support more custom orderings in the future to align with the new Code Actions on Save enums.

@dockleryxk
Copy link

@justschen Sweet!!! I bring this up because a common workflow I've seen is running format with prettier and then following it with eslint to make some tweaks.

Either way, thank you for going back and fixing the array version of the setting in #194870 :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug candidate Issue identified as probable candidate for fixing in the next release verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

8 participants