Closed cgbur closed 2 years ago
Thanks for looking into this! It's good to know that this kind of change fixes the rust analyzer case.
We rarely see diffs change more than one range, so an alternative implementation would be the following.
Some additional rationale:
I agree with your implementation suggestion and that was my first attempt but went with the external dependency approach for correctness sake. I got a headache thinking about edge cases. willing to rewrite when I get more time.
Implemented your suggestion! Much cleaner, thanks for the inspiration.
I appreciate that you're being conscious of performance, given how critical it is for an app like this. I made the proposed changes and then benchmarked them in this PR: https://github.com/serenadeai/code/pull/40
Please let me know if this still solves the problem for you.
The current serenade application replaces the entire text inside VS Code whenever a change is made. This results in a negative user experience when using certain applications that rely on a language server. In particular, when using Rust-analyzer, any changes that were made would result in all of the types going away and having to be re-loaded/re-computed.
This pull request adds the functionality to compare the differences between the old and new files. A change list is then made and each one is applied. Local testing seems to show that this is working well and rust analyzer no longer complains. There seem to be no regressions.
I doubt this code is up to your internal standards and encourage you to edit it and make changes.
There is an open question whether or not we will ever see disparate changes. In this code, after the deletion section of the difference, the columns and rows are reset back to their previous value to mimic what would happen when the text is deleted. I believe this is unnecessary as serenade will only ever make one change at a time, so this code could be optimized or changed a bit.