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 10:20:39 +0100 Message-ID: <87y1rqnouw.fsf@thornhill.no> References: <9F4F5716-F492-479A-869F-94D8A9391285@gmail.com> <83v8mufbd2.fsf@gnu.org> 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="25716"; mail-complaints-to="usenet@ciao.gmane.io" Cc: bruce.stephens@isode.com, casouri@gmail.com, 59686@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Dec 02 10:21:27 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 1p12EZ-0006Pb-2l for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 02 Dec 2022 10:21:27 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p12EC-0002NJ-BS; Fri, 02 Dec 2022 04:21: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 1p12EA-0002N5-KQ for bug-gnu-emacs@gnu.org; Fri, 02 Dec 2022 04:21:02 -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 1p12EA-0003P6-9W for bug-gnu-emacs@gnu.org; Fri, 02 Dec 2022 04:21:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p12EA-0004Vt-4h for bug-gnu-emacs@gnu.org; Fri, 02 Dec 2022 04:21: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 09:21: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.166997284617322 (code B ref 59686); Fri, 02 Dec 2022 09:21:02 +0000 Original-Received: (at 59686) by debbugs.gnu.org; 2 Dec 2022 09:20:46 +0000 Original-Received: from localhost ([127.0.0.1]:45549 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p12Du-0004VK-7B for submit@debbugs.gnu.org; Fri, 02 Dec 2022 04:20:46 -0500 Original-Received: from out2.migadu.com ([188.165.223.204]:44204) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p12Dr-0004VD-3h for 59686@debbugs.gnu.org; Fri, 02 Dec 2022 04:20:44 -0500 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. In-Reply-To: <83v8mufbd2.fsf@gnu.org> 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:249728 Archived-At: Eli Zaretskii writes: >> Cc: 59686@debbugs.gnu.org >> Date: Fri, 02 Dec 2022 06:42:03 +0100 >> From: Theodor Thornhill via "Bug reports for GNU Emacs, >> the Swiss army knife of text editors" >>=20 >> >> // -*- 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= where >> >the "{" is on, and indents from there. Theo, WDYT? Does indent style=20 >> >fix this, or we should change the indent rules? >> > >> >Yuan >>=20 >> I've seen this issue myself, and have tried several combinations to fix = it. It is trivial to fix this particular case, but because compound_stateme= nt is used everywhere problems will pop up other places. The fix here would= be some grand-parent-bol function, but if my memory serves that would mess= up the else in an if else. I'm happy to see this fixed, but just remember = that it's not _super_ trivial. >>=20 >> Other languages exhibit similar issues, but with other constructs. > > FWIW, this is an unusual style, so I see no catastrophe if it is not 110% > according to expectations. Users can easily fix that by tweaking their B= OLs > where important. Yeah, that was my reasoning as well. I think we should come up with some preset that can do this, but maybe when we know even more about how to deal with similar edge cases?