Skip to content
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

Conflicts between language server and forc-fmt #4893

Closed
JoshuaBatty opened this issue Jul 31, 2023 · 0 comments · Fixed by #5094
Closed

Conflicts between language server and forc-fmt #4893

JoshuaBatty opened this issue Jul 31, 2023 · 0 comments · Fixed by #5094
Assignees
Labels
bug Something isn't working formatter language server LSP server

Comments

@JoshuaBatty
Copy link
Member

This was reported by @Braqzen on Slack.

When I have a script open in VSCode there is a little floating thingy that pops up above the main() function which allows me to run it.
In a terminal that is external to VSCode when I run the forc formatter it formats the script; however, from that point onward the floating pop up for running the script no longer appears.

I suspect this is caused by forc-fmt saving the file after it completes. Because the language server is operating in temporary memory this change might not be getting sync'ed with this location leading to AST's that aren't matching.

@JoshuaBatty JoshuaBatty added bug Something isn't working language server LSP server formatter labels Jul 31, 2023
@JoshuaBatty JoshuaBatty self-assigned this Jul 31, 2023
JoshuaBatty added a commit that referenced this issue Sep 15, 2023
…sway-lsp` interaction. (#5094)

## Description
This PR adds 3 things:

1. Adds a benchmark for the format LSP request.

2. Calls `session.wait_for_parsing();` before computing the `code_lens`
request. This fixes the original issue reported in #4893 where run
buttons where being placed incorrectly after formatting.

3. 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. If `forc-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.


https://github.com/FuelLabs/sway/assets/1289413/75e6fddc-adbc-4796-aeb9-985574ae8dcc


closes #4893
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working formatter language server LSP server
Projects
None yet
1 participant