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

Text format to return edited ranges instead of entire document #579

Merged
merged 4 commits into from
Aug 23, 2022

Conversation

jefftime
Copy link
Contributor

@jefftime jefftime commented Aug 13, 2022

This pull request addresses the current behavior of ZLS's text formatting. Currently, ZLS will return the result of zig fmt as the replacement text for the entire range of the document. This causes odd issues in certain text editors such as Helix which lose cursor position due to the whole document being changed

This pull request adds the ability to compare the input text and the zig fmt output in order to get proper text edit ranges. I am not an expert on the LSP specification by any means, but I believe this is more in mind with how text formatting is supposed to behave. In most cases it should allow for smaller messages between the client and server as well

@leecannon
Copy link
Member

You are going to need to rebase on master to get the CI passing.

@jefftime
Copy link
Contributor Author

@leecannon Done

Copy link
Member

@leecannon leecannon left a comment

Choose a reason for hiding this comment

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

Seems to work fine in vscode, I'm not setup for testing in any other editor.

@leecannon leecannon merged commit 163409f into zigtools:master Aug 23, 2022
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