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

source.fixAll: true removes unreachable code #159599

Closed
jeffrson opened this issue Aug 30, 2022 · 3 comments
Closed

source.fixAll: true removes unreachable code #159599

jeffrson opened this issue Aug 30, 2022 · 3 comments
Assignees
Labels
*as-designed Described behavior is as designed editor-code-actions Editor inplace actions (Ctrl + .) javascript JavaScript support issues typescript Typescript support issues

Comments

@jeffrson
Copy link

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version: 1.70.2
  • OS Version: Windows 10

Steps to Reproduce:

  1. Use this settings.json
{
  "editor.codeActionsOnSave": {
    "source.fixAll": true
  }
}
  1. Edit a file
console.log(1)
return
console.log(2)
  1. Press Ctrl-S to save - everything after 'return' is removed.

AFAICT, VSCode should not delete code like this. Yes, I could "source.fixAll": false, but this would interfere with real autofixes.
Also, there's no hint to be seen, that anything might be wrong with the code - Ctrl-. shows "No code actions available". The "fix" cannot be disabled.

BTW, is there any documentation, what "source.fixAll" is supposed to do without any extension that makes use of it?

Obviously this is a very annoying bug, since you cannot simply "disable" following parts of the code for testing.

@jeffrson jeffrson changed the title source.fixAll": true removes unreachable code source.fixAll: true removes unreachable code Aug 30, 2022
@mjbvz mjbvz added typescript Typescript support issues javascript JavaScript support issues editor-code-actions Editor inplace actions (Ctrl + .) labels Sep 21, 2022
@mjbvz mjbvz added the *as-designed Described behavior is as designed label Dec 5, 2022
@VSCodeTriageBot
Copy link
Collaborator

The described behavior is how it is expected to work. If you disagree, please explain what is expected and what is not in more detail. See also our issue reporting guidelines.

Happy Coding!

@VSCodeTriageBot VSCodeTriageBot closed this as not planned Won't fix, can't repro, duplicate, stale Dec 5, 2022
@jeffrson
Copy link
Author

jeffrson commented Dec 9, 2022

Sorry - I can't believe you're closing just by "behavior is how it is expected to work" without further explanation regarding my points.

IMO, inserting "return" just to disable part of code temporarily is not too uncommon of a workflow (much shorter and quicker than commenting). Then, "save" removes all this only temporarily disabled code. This way, the source code is heavily changed in its overall meaning what never should be done by any "autocorrection".

Also, there's no indication of some "error" that should be corrected. So removing the code is quite unexpected.

Furthermore, there is no documentation what "source.fixAll: true" actually does. And there's no way to configure what it does.

I now have '"source.fixAll": false', but I think this may change how "real autofixes" (eslint, prettier) behave.

@nghieptiki
Copy link

Same issue source.fixAll: false doesn't solve the problem.

@github-actions github-actions bot locked and limited conversation to collaborators Jan 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
*as-designed Described behavior is as designed editor-code-actions Editor inplace actions (Ctrl + .) javascript JavaScript support issues typescript Typescript support issues
Projects
None yet
Development

No branches or pull requests

4 participants