From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Theodor Thornhill via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#59686: 30.0.50; tree-sitter indentation in some loops and conditional statements is wrong Date: Fri, 02 Dec 2022 06:42:03 +0100 Message-ID: References: <9F4F5716-F492-479A-869F-94D8A9391285@gmail.com> Reply-To: Theodor Thornhill Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="6326"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 59686@debbugs.gnu.org To: Yuan Fu , bruce.stephens@isode.com Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Dec 02 06:50:16 2022 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 1p0ywB-0001Ue-Rf for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 02 Dec 2022 06:50:15 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p0ypF-000795-Ap; Fri, 02 Dec 2022 00:43:05 -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 1p0ypD-00075a-Ac for bug-gnu-emacs@gnu.org; Fri, 02 Dec 2022 00:43: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 1p0ypC-0005aK-QE for bug-gnu-emacs@gnu.org; Fri, 02 Dec 2022 00:43:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p0ypC-0001hW-Gw for bug-gnu-emacs@gnu.org; Fri, 02 Dec 2022 00:43:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Theodor Thornhill Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 02 Dec 2022 05:43:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59686 X-GNU-PR-Package: emacs Original-Received: via spool by 59686-submit@debbugs.gnu.org id=B59686.16699597626531 (code B ref 59686); Fri, 02 Dec 2022 05:43:02 +0000 Original-Received: (at 59686) by debbugs.gnu.org; 2 Dec 2022 05:42:42 +0000 Original-Received: from localhost ([127.0.0.1]:44305 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p0yos-0001hH-7w for submit@debbugs.gnu.org; Fri, 02 Dec 2022 00:42:42 -0500 Original-Received: from out-205.mta0.migadu.com ([91.218.175.205]:56905) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p0yom-0001hB-G0 for 59686@debbugs.gnu.org; Fri, 02 Dec 2022 00:42:40 -0500 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. In-Reply-To: <9F4F5716-F492-479A-869F-94D8A9391285@gmail.com> 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:249705 Archived-At: On 2 December 2022 06:13:42 CET, Yuan Fu wrote: > >Bruce Stephens writes: > >> With the following file I would expect foo(i) to be indented to just tw= o >> indents (like the first one), but they are not=2E Similarly for many ot= her >> compound statements where the opening spans more than one line=2E >> >> // -*- c-ts -*- >> int main() { >> for (int i=3D0; i<10; ++i) { >> foo(i); >> } >> >> for (int i=3D0; >> i<10; >> ++i) { >> foo(i); >> } >> } > >I see, that=E2=80=99s because the indent rule finds the BOL of the line w= here >the "{" is on, and indents from there=2E Theo, WDYT? Does indent style= =20 >fix this, or we should change the indent rules? > >Yuan I've seen this issue myself, and have tried several combinations to fix it= =2E It is trivial to fix this particular case, but because compound_stateme= nt is used everywhere problems will pop up other places=2E The fix here wou= ld be some grand-parent-bol function, but if my memory serves that would me= ss up the else in an if else=2E I'm happy to see this fixed, but just remem= ber that it's not _super_ trivial=2E Other languages exhibit similar issues, but with other constructs=2E Lastly, I _did_ fix most of these, but that required using query as the ma= tcher in simple-indent-rules, which made indenting slower, and I needed one= rule for almost every construct in a language=2E I'm sure she fix can be simple, but I'm a little blind to it right now=2E = My eyes are bleeding tree-sitter nodes at the moment, so I might not see cl= early :P