-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Synchronize code_lens request & provide better UX for forc-fmt
<> sway-lsp
interaction.
#5094
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
What if the user changes their files on disk using something different from I believe, if possible, it would be nice to have |
Yeah I agree this would be ideal. I'm going to put this PR in draft mode while I ponder on this a bit more. Thanks Anton |
Not sure what's the best approach here, but just as another data point, Cargo and rust-analyzer also seem to have some kind of integration, as if cargo is running from the VS Code LSP session, then cargo from the command line will wait until it's finished before starting. |
Ah, that's interesting, didn't know about that integration. I'd guess they use some kind of file system lock. @tritao can you share some more details how they do it? |
I don't know how they do it, but I would assume a filesystem lock too. |
This is the message I see: |
We should get thing 1 and thing 2 in regardless!
Taking a lock on the build directory is clever because it links it to the specific sway project, doesn't prevent editing the file in other editors at the same time, and should only ever be touched by forc. Both forc-fmt and forc-client (forc build) would also need to wait for a lock on the build directory. We could have LSP take a lock on the build directory on |
It's actually pretty fast. Averaging ~98ms to complete. I think the slowness is coming from the client <> server interaction. |
Thanks for the tips everyone. I'm going to look into a nice solution this week. |
4c95f5d
to
607119f
Compare
Ok i'm pretty happy with this now. Any unsaved changes for a file in LSP now creates a hashed lock file in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just need to clean up eprintlns
049b8e2
to
45fb2ec
Compare
45fb2ec
to
700ee44
Compare
Description
This PR adds 3 things:
Adds a benchmark for the format LSP request.
Calls
session.wait_for_parsing();
before computing thecode_lens
request. This fixes the original issue reported in Conflicts between language server and forc-fmt #4893 where run buttons where being placed incorrectly after formatting.If a file open in a code editor contains unsaved changes we write a lock file to
.forc/lsp_locks/
. This file is removed when the file is saved and there are no pending changes. Ifforc-fmt
is run in a terminal we check if the path has a lock file associated with it. If unsaved changes are detected we bail from formatting with an error message instructing the user to save changes before continuing. See video below.Screen.Recording.2023-09-13.at.4.34.34.pm.mov
closes #4893
Checklist
Breaking*
orNew Feature
labels where relevant.