|
From: | Dmitry Gutov |
Subject: | bug#61017: 29.0.60; ruby-ts-mode indents class between two lines incorrectly |
Date: | Wed, 25 Jan 2023 06:00:11 +0200 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 |
On 25/01/2023 02:45, Aaron Jensen wrote:
Is it enough of an improvement?That seems to make indentation after an open def not happen: def foo bar endNot sure what you mean. Is that an example with an "open def"? "end" seems to be closing it. In the final state, it indents correctly here.Sorry, that's what I meant. If I do type exactly that and do not reindent, I end up with that though (closing with the end does not cause the previous line to reindent)
All right.But if the proposed patch doesn't make things worse for this example, we might as well install it. Because this "unclosed def" case is distinct from the one you filed this bug report regarding.
I applied the patch manually though, so maybe you can confirm that you see the same thing?If I have a buffer with just the first line: def foo then it indeed doesn't indent. But I think that happens with or without this patch? It's a slightly different problem: the grammar parses this code example without ERROR nodes, like a full method, for some reason: (program (method def body: (identifier) end)) And the end position of the "virtual" end node stays at the previous line, so our code doesn't know it's inside the method. I suppose we could add some tricky predicate like (is the previous node a method with an "end" child that is 0 characters long), but the grammar might change (we should look for any previous reported issues about this behavior, or maybe ones that resulted in it), and it only happen this way when there is nothing after "def xyz" in the buffer.I wonder if this is mistaken handling of endless methods?
Those parse to nodes that look a little different (no "end"): (program (method def body: (identifier) = (integer))) So I'm not sure.
I can't think of a reason that it would parse like that. Should that be reported upstream?
I filed https://github.com/tree-sitter/tree-sitter-ruby/issues/234, let's see if there is any response.
[Prev in Thread] | Current Thread | [Next in Thread] |