From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Aaron Jensen Newsgroups: gmane.emacs.bugs Subject: bug#61017: 29.0.60; ruby-ts-mode indents class between two lines incorrectly Date: Tue, 24 Jan 2023 19:45:13 -0500 Message-ID: References: <1a2436ef-ff4d-827c-f22f-33b0737d9b1f@yandex.ru> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="8044"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 61017@debbugs.gnu.org To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Jan 25 01:46:21 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pKTvh-0001xs-C1 for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 25 Jan 2023 01:46:21 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pKTvQ-0002U9-OU; Tue, 24 Jan 2023 19:46:04 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pKTvP-0002Tz-8K for bug-gnu-emacs@gnu.org; Tue, 24 Jan 2023 19:46:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pKTvP-0002W4-0Y for bug-gnu-emacs@gnu.org; Tue, 24 Jan 2023 19:46:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pKTvO-0004B5-EC for bug-gnu-emacs@gnu.org; Tue, 24 Jan 2023 19:46:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Aaron Jensen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 25 Jan 2023 00:46:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 61017 X-GNU-PR-Package: emacs Original-Received: via spool by 61017-submit@debbugs.gnu.org id=B61017.167460753416019 (code B ref 61017); Wed, 25 Jan 2023 00:46:02 +0000 Original-Received: (at 61017) by debbugs.gnu.org; 25 Jan 2023 00:45:34 +0000 Original-Received: from localhost ([127.0.0.1]:57864 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pKTuv-0004AG-N3 for submit@debbugs.gnu.org; Tue, 24 Jan 2023 19:45:34 -0500 Original-Received: from mail-pj1-f46.google.com ([209.85.216.46]:35411) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pKTut-00049v-46 for 61017@debbugs.gnu.org; Tue, 24 Jan 2023 19:45:32 -0500 Original-Received: by mail-pj1-f46.google.com with SMTP id n20-20020a17090aab9400b00229ca6a4636so425185pjq.0 for <61017@debbugs.gnu.org>; Tue, 24 Jan 2023 16:45:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=q4XTv3Xr++Kh3h/Iz98zFXzm7/FXRpFQLQ6eFWJnD8Y=; b=fDJWK9jZjff4ImyPRtA+AFttEtaeKGFMvV73CCJ5KEwCwr3T+xiOHKKVJJm7cK1gJN IDWAyVfn4+Xoi922TNRflJLbPZHj4ySecNdDaSOrp74ljMlgVUW13jSzEQ8bQiORhBrE TdbHBPH7ucjZiDB77qis0XdvgNVcSViSBkNnn3dmAcE4vU8gzGa6ankFe7nHGzRV6Q5j 2H2h699f/v3GHXZHU/2fj2JwVRx4w5XPzagHG/gs1wj70rUc8p3GRDQqfQ85HIcEAeUw ifQegPzwEzCo6l+/0XeAO7AHpNOfCbmh3G1nuv22EceDkL5tmsR2tuLMT4Vgf0kTZR9R 0BFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=q4XTv3Xr++Kh3h/Iz98zFXzm7/FXRpFQLQ6eFWJnD8Y=; b=qEiiVBH9hZI1BLYd6k9PezHGagNuPZ4FU7gz0Yjbuq701AgDxVJQubCUH/7KPR1Jum XW7Vze4zW8TLFz9XBPcZxn33wxx2HIL/5+lpUYm+Zz5sneV0lc/Lw+2ANc8CgkuCnydd AcH+V0E+cb7vIQo6IDIKREhpwI0e0NsIcrM5tzkCK4m3rnpJbHJ5IwQ11KhKKO27VsIq nuOnxMbn9UuuMTAVrCvH8wqZZpJcLbe9nvlpwjPUF3JwxQbjJfzBBugS5HNMgQAkmODI PHUvaD4dTFbJo8OEK+sr+XVX+BGjHiTzFBXHTKkgBjKqaVFnAObkgpHnNZSAhqfTyxdf fu2w== X-Gm-Message-State: AFqh2krPWV3lMKD52FU5xcYfDvBYlg18pkfodTQK5yG80866lG6nYPmW odQdQTLa/DGF/pwKMkGYxRYryVORx2a8oGV3RBs= X-Google-Smtp-Source: AMrXdXuJcocl4RP4TtTCYbdLkbMQ9d2SAj6neX5UOoTlyu/dT8JuIUYczJhupmOT79q4E2TLBpf+outc7R+5Q+sZH+8= X-Received: by 2002:a17:90a:ec17:b0:22b:b1ac:dd21 with SMTP id l23-20020a17090aec1700b0022bb1acdd21mr1791408pjy.69.1674607524961; Tue, 24 Jan 2023 16:45:24 -0800 (PST) In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:254085 Archived-At: On Tue, Jan 24, 2023 at 1:53 PM Dmitry Gutov wrote: > > On 24/01/2023 16:17, Aaron Jensen wrote: > > On Mon, Jan 23, 2023 at 4:28 PM Dmitry Gutov wrote: > >> > >> Hi! > >> > >> On 23/01/2023 06:33, Aaron Jensen wrote: > >>> > >>> Start with a buffer in ruby-ts-mode like: > >>> > >>> a > >>> > >>> b > >>> > >>> Between the two lines, type "class Foo", then press enter > >>> > >>> You should get this: > >>> > >>> a > >>> > >>> class Foo > >>> > >>> b > >>> > >>> But this is expected: > >>> > >>> a > >>> > >>> class Foo > >>> > >>> b > >>> > >>> Note that reindenting after adding the "end" will indent correctly, so > >>> it's only an issue with electric indent > >> > >> Thanks for the report, the problem here is that such examples parse into > >> a malformed syntax tree: > >> > >> (program (identifier) > >> (ERROR class (constant) (identifier))) > >> > >> Another example would be: > >> > >> class C > >> def foo > >> > >> which parses as > >> > >> (ERROR class (constant) def (identifier)) > >> > >> We can try to anticipate such cases and infer the implied structure > >> somehow, or just disable indentation for specific cases. See the > >> attached patch for the latter. > >> > >> Is it enough of an improvement? > > > > That seems to make indentation after an open def not happen: > > > > def foo > > bar > > end > > Not 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) > > > 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? I can't think of a reason that it would parse like that. Should that be reported upstream? > Because in the more common case, like > > class C > def foo > | > end > > the last "end" is parsed like the closer for the method, the method node > spans until it, and the line with "|" indents correctly. > > WDYT?