Replies: 1 comment 3 replies
-
Hey @ydaveluy, we used to have code like that, see: However, this led to a lot of issues in the formatter in case there are conflicting formattings for the same tokens. In that case, the formatter has shown cyclic behavior - everytime you perform the formatting you get a different result. I haven't found a good solution for this yet, so we disabled the behavior again. We would probably need a post-processing phase after running the |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The current formatter implementation returns an array of all text edits, even if the document is already properly formatted and there are no changes to be made.
This array is then returned to VSCode, which applies all the edits.
By filtering the returned edits, overall performance is improved by 20% to 30%.
For example, on a reference DSL with 240,000 lines, formatting time is reduced from 4.6 seconds to 3.5 seconds.
You can see the relevant code here:
langium/packages/langium/src/lsp/formatter.ts
Line 161 in b2c40e3
The following code shows how to filter the edits:
Beta Was this translation helpful? Give feedback.
All reactions