lsp-java icon indicating copy to clipboard operation
lsp-java copied to clipboard

After I save a file, LSP updates the file but does not refresh the buffer

Open joe-humphreys opened this issue 2 years ago • 1 comments

Describe the bug Every time I save a Java file, LSP's save hooks run, which usually results in the file being changed on disk. However, the buffer where I am visiting the file does not get refreshed. So when I go to make further changes, I get a message <filename> changed on disk; really edit the buffer? (y, n, r or C-h). Effectively, that means every time I save, I have to wait a moment and then hit 'r' before doing further edits, which is very distracting.

To Reproduce

  1. Open a java file.
  2. Go to any line with code on it and add a few spaces at the beginning of the line.
  3. Save the file
  4. Begin typing

Expected behavior If a background process changes a file I've got open in a buffer, the changes should just show up immediately in the buffer, without prompting me to revert.

Logs Content of Messages buffer with lsp-print-io set to t: LSP :: Disconnected LSP :: Connected to [jdtls:15943 /home/joh/git/mailific/mailific-spf]. Saving file /home/joh/git/mailific/mailific-spf/src/main/java/net/mailific/spf/Spf.java... Wrote /home/joh/git/mailific/mailific-spf/src/main/java/net/mailific/spf/Spf.java Spf.java changed on disk; really edit the buffer? (y, n, r or C-h) r LSP :: Disconnected LSP :: Connected to [jdtls:15943 /home/joh/git/mailific/mailific-spf]. ask-user-about-supersession-threat: File reverted: ~/git/mailific/mailific-spf/src/main/java/net/mailific/spf/Spf.java

joe-humphreys avatar Jul 18 '23 21:07 joe-humphreys

It seems do not caused by lsp-java. I can't find a hook named lsp-save-hook. did other file have this error eithor when you save them? If so check your emacs self setting maybe help .

sincebyte avatar Sep 19 '23 14:09 sincebyte