rescript-vscode
rescript-vscode copied to clipboard
Feature: format selection
I'm new to ReScript and I've been trying the VS Code extension with Format on Save enabled. However, I'd like to manually control formatting with the Format Selection command (more on my reasons here). But the extension's formatter only seems to support whole file formatting. Neither Format Selection, nor setting the Format on Save Mode to "modifications", seem to do anything.
This would be an important feature for me since I don't think I can carry on with Format on Save enabled (I don't like some of the formatter's behaviour) but I'd like to stick to standard formatting as much as possible so it would help a lot with that.
I don't know if this is an issue with the extension or with the formatter itself being unable to handle partial content, but I thought I'd create the issue for the component where I experience the problem.
Curious, how does formatting like this typically work? Is it typically resilient to selecting a syntactically invalid ranges?
Hmm, good question. I'd imagine so. In my experience, formatting tools simply tend to terminate (ie. return the remaining contents unchanged) at the point where they encounter a syntax error. Is that not how the ReScript formatter behaves? Would that be enough to make it resilient?
I suppose the other thing to consider is if it's provided a selection which isn't entirely linewise (say a block together with its enclosing braces which is itself part of a function definition), but I'd perhaps count that as misuse and accept any weird formatting that results.