Skip to content

Enable forc fmt to operate on the LSP tmp files so it can format unsaved changes. #6787

@JoshuaBatty

Description

@JoshuaBatty

There has been a few reports on Slack where people are running into problems with the lsp_lock files disabling the ability to run forc fmt

from Cam

I'm still getting this error every once in a while. The solution has been to delete .forc/.lsp-locks/. I think it has to do with the fact that I have multiple instances of VSCode open across multiple repos i.e. sway, sway-standards, sway-libs, my test projects, etc. I haven't found a consistent way to reproduce it.

from Swayam

I only have one vscode open so I don't think there being multiple is the problem

Screenshot 2024-12-11 at 12 53 45

If we just consider the following scenario. A user is editing a file in vscode with unsaved changes. They then run forc fmt in the in built terminal. This will produce the error above. This is because forc fmt is only operating from the saved file on disk which contains the unsaved changes.

One idea is instead of just locking this operation, we could use the file saved in .forc/.lsp-locks/ to contain the path to the file in tmp. This way, forc fmt could then get access to the unsaved changes and still run formatting on the file that lsp is operating on. This would remove the need for locking the forc fmt process.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions