After I save a file, LSP updates the file but does not refresh the buffer
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 38/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- emacs-lisp, java
- Domain
- developer-experience, tooling
Research direction
Reproduce the issue with a Java file by adding spaces, saving, and typing immediately afterward. Trace the LSP save hooks and buffer refresh behavior; done means background file changes appear in the open buffer without the supersession prompt or manually reverting.
Written by the indexing model from the issue text.
Description
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
- Open a java file.
- Go to any line with code on it and add a few spaces at the beginning of the line.
- Save the file
- 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
- Dominant language
- Emacs Lisp
- Stars
- 696
- Forks
- 97
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from emacs-lsp/lsp-java
-
dap-java discards module paths from resolveClasspath causing JPMS-modular projects fail to launchOpen
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
-
Difficulty 3/5 1-2 days Newbie friendliness 58/100
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
All issues in emacs-lsp/lsp-java
Similar issues
-
documentation from-review-extraction github-actions priority: low severity:nit
Difficulty 1/5 Under an hour Newbie friendliness 92/100
LearningCircuit/local-deep-research#6946 ·
Maintainers usually reply within 1 day
-
Help-Wanted Needs-Triage Package-Request
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
microsoft/winget-pkgs#442309 ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
alunduil/zfs-replicate#730 ·
Maintainers usually reply within 1 day
-
infrastructure
Difficulty 1/5 1-3 hours Newbie friendliness 65/100
alunduil/siren-json.hs#232 ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
alunduil/alunduil-infrastructure#629 ·
Maintainers usually reply within 1 day