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

LSP-based formatting does not use snapshots to ensure edits are applied correctly #22932

Open
1 task done
mgsloan opened this issue Jan 9, 2025 · 2 comments
Open
1 task done
Assignees
Labels
bug [core label] editor Feedback for code editing, formatting, editor iterations, etc

Comments

@mgsloan
Copy link
Contributor

mgsloan commented Jan 9, 2025

Check for existing issues

  • Completed

Describe the bug / provide steps to reproduce it

With the changes in #22929 the behavior is to resolve anchors to points in the current buffer snapshot. This is an improvement over the state before, where these points were computed in editor.rs.

There are two ways snapshots should be used here:

  • To know the point ranges to send to the LSP.
  • To apply edits from the LSP correctly.

It might not be great to rely on commutative edits here. The best thing to do might be to abort a particular selection or buffer's formatting if there are conflicts, maybe even with some limited retry.

Zed Version and System Specs

N/A

If applicable, add screenshots or screencasts of the incorrect state / behavior

No response

If applicable, attach your Zed.log file to this issue.

No response

@mgsloan mgsloan added bug [core label] editor Feedback for code editing, formatting, editor iterations, etc labels Jan 9, 2025
@mgsloan mgsloan self-assigned this Jan 9, 2025
@failable
Copy link

failable commented Jan 10, 2025

When I run editor: format selection on selected region, the whole buffer is formatted. Is this related?

@mgsloan
Copy link
Contributor Author

mgsloan commented Jan 10, 2025

@failable Probably unrelated. Most likely reason is because some language servers do not support formatting a selected region.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug [core label] editor Feedback for code editing, formatting, editor iterations, etc
Projects
None yet
Development

No branches or pull requests

2 participants