Closed zedeus closed 6 years ago
I've done a quick scan through our code and (what I think is) the appropriate code in YCMD itself, and I think emacs-ycmd is doing the right thing WRT to the ycmd protocol. We're sending the current buffer contents, it's expecting those, etc. I'm willing to assume for now that ycmd itself is doing the right thing regarding unsaved buffer contents. So...
@ptrv Is it possible that we're simply showing diffs against the saved file instead of the in-buffer contents? You know this part of the code much better than I do.
@abingham Yes, you are right, we are showing the diff against the local copy of the file.
Here: https://github.com/abingham/emacs-ycmd/blob/1806b6a9d00946f06b42bb218b3839a392b8a95e/ycmd.el#L1596
We use the filepath
to diff against current-buffer
for diff-no-select
and it should be the
buffer
from 5 lines above.
This is due to diff-no-select
is using the local copy if you provide the filepath instead of a buffer.
@zestyr I've pushed a change to the fix-fixit-diff
branch. Could you give it a try and let me know if it works for you? I've taken it for a small test-drive, and it seems to work, but I'd like to verify that it solves your problem as well.
@abingham It works indeed, thank you for the fix. Sorry for the delay.
No worries. Thanks for testing it out.
When ycmd parses a C buffer with changes and suggests a FixIt, the chunk diffs shown use the unsaved file. This results in errors made after saving the file not being diffed properly, as well as showing unrelated changes. I haven't tested with languages other than C, so I don't know if this is a general issue.
Without saving:![image](https://user-images.githubusercontent.com/9434921/42359840-02caf056-80e5-11e8-80e4-03efe2e996ab.png)
After saving:![image](https://user-images.githubusercontent.com/9434921/42359827-dc40dcd4-80e4-11e8-942a-e3086222424d.png)
Debug info: