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

Implement Code actions with autofix #673

Merged
merged 8 commits into from
Sep 25, 2022

Conversation

Techatrix
Copy link
Member

@Techatrix Techatrix commented Sep 25, 2022

This PR adds code actions that fix unused variable and pointless discard errors.
There is also a new config option called enable_autofix (off by default) which as name may indicate will automatically fix these errors when you save your file. This is essentially the same as Andrew's --autofix ziglang/zig#12803.


output1

Autofix in action

output2
Just save your file and all the work is done for you.


I've tested this feature on VS Code and Sublime Text 4. Autofix for the helix editor is currently blocked on helix-editor/helix#3957

@Techatrix Techatrix merged commit e776a5c into zigtools:master Sep 25, 2022
@Techatrix Techatrix deleted the code-actions branch September 25, 2022 01:12
IntegratedQuantum added a commit to IntegratedQuantum/zls that referenced this pull request Sep 28, 2022
…tools#673).

The previous implementation always assumed spaces for indentation.
But in stage2 code may contain tabs for indentation as well.
SuperAuguste pushed a commit that referenced this pull request Oct 13, 2022
* Allow tabs for the indentation added by the code actions feature (#673).

The previous implementation always assumed spaces for indentation.
But in stage2 code may contain tabs for indentation as well.

* Fix some edge cases, properly detect indentation(any amount of spaces) and move the indentation code inside `createDiscardText()`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants