Closed antifuchs closed 7 months ago
This is a helpful observation and I think this could definitely be improved. It sort of makes sense that this is what's happening, considering how the tree-sitter nodes are parsed. I think a more intuitive parse functionality could definitely be made. Perhaps if the point is on whitespace at the beginning of the line, it could count as if it was the node of the first character on the line.
Sorry for not getting to this sooner. The version of the function without treesitter (yaml-pro-indent-subtree
) does have some weird bugs. I think that moving the point to the first character on the line and then doing the indent should fix this and remove strange behavior.
If it's possible with our current version, I would definitely recommend switching to the treesitter version of the package (yaml-pro-ts-mode
and yaml-pro-ts-indent-subtree
) as the tree-sitter parser is much faster and results in fewer bugs.
First I thought
yaml-pro-indent-subtree
was broken, but it has a kind of twisted logic! With the following code:point at column 0:
With point at the very beginning of the line of the
foo:
key, ayaml-pro-indent-subtree
will result in:point at column 1:
With point one character ahead, the tree results in:
... it indents both the
bar:
andfoo:
subtree. Weird, also not what I meant to do. But at least the syntax checks out!point at column 2:
That's what I actually meant to do!
Special case:
foo
at column zeroThis does the right thing, resulting in a buffer transform from:
to:
but point remains at column 0, which means that if I attempt to unindent the tree again, it'll catch the wrong target & unindent the
y
key above it.