Open plexus opened 3 years ago
Thanks. This reminds me that we should probably try to document how the editor.autoIndent
setting plays together with Calva.
To clarify the nature of this bug I'd like to note that this is only happens at the top level. (I know it says so in the title, but anyway.)
So:
(foo
(bar|)
(baz))
Slurp forward! =>
(foo
(bar|
(baz)))
Barf forward! =>
(foo
(bar|)
(baz))
as expected.
The current mechanism for selecting what should be formatted does not lean itself super well to this problem. Let me try to explain how it works (for anyone that picks this up and want to try to fix it):
levels
argument which determines how many levels of enclosing forms should be formattedlevels
argument is used to format enough structure. barf
needs two levels, slurp sometimes needs more, for instance.When we reach the top level things break down a bit. Formatting that whole level is quite dramatic for many files, so I didn't want to do that. And I couldn't then (when implementing the post-edit formatting) find a clean way to determine how much should actually get formatted. It could be argued that I shouldn't label this issue as a bug
, since it is rather a multi-headed trade-off, but also it is inconsistent how it behaves....
Thanks for explaining! Is there a way to tell it to format more than one form at the same level, rather than having to go a level up?
We can use paredit or the token cursor it uses to select what should be formatted.
I've created a bit of a monster here, so the trickier part is to manage to inject new selection strategy without making it all completely incomprehensible.
The selection will have two parts to it, I think:
In both cases we need to take that first thing into account. 😀
settings.json
Given this form with
|
indicating the cursorWhen invoking
Calva Paredit: Bard Sexp Forward
, you get thisExpected: