-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Description
At the moment, rust-analyzer wraps the entire file returned from rustfmt in a single TextEdit
in the response to a textDocument/formatting
request. This may cause the client cursor to end up far from its original position after formatting. It should not be that difficult to apply a diffing algorithm to the original file contents and rustfmt output to send many smaller TextEdit
s instead.
The difference in behaviour would be small in VSCode, as that editor does diffing on the client side to split the edits, but in other editors (like neovim, which I use), this can mean not losing all marks or having to find the place one is working again after formatting.
You could consider this as being fixed/blocked by #1665, but I think it may be nice to just do some simple diffing first