From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii 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:39:21 +0200 Message-ID: <83v8mufbd2.fsf@gnu.org> References: <9F4F5716-F492-479A-869F-94D8A9391285@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24560"; mail-complaints-to="usenet@ciao.gmane.io" Cc: bruce.stephens@isode.com, casouri@gmail.com, 59686@debbugs.gnu.org To: Theodor Thornhill Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Dec 02 09:40:13 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 1p11ae-0006AV-Pv for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 02 Dec 2022 09:40:13 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p11aW-0000rb-FW; Fri, 02 Dec 2022 03:40: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 1p11aU-0000qu-3U for bug-gnu-emacs@gnu.org; Fri, 02 Dec 2022 03:40: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 1p11aT-0006ak-QD for bug-gnu-emacs@gnu.org; Fri, 02 Dec 2022 03:40:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p11aT-0003tW-NL for bug-gnu-emacs@gnu.org; Fri, 02 Dec 2022 03:40:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 02 Dec 2022 08:40:01 +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.166997039514958 (code B ref 59686); Fri, 02 Dec 2022 08:40:01 +0000 Original-Received: (at 59686) by debbugs.gnu.org; 2 Dec 2022 08:39:55 +0000 Original-Received: from localhost ([127.0.0.1]:45364 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p11aM-0003tC-JO for submit@debbugs.gnu.org; Fri, 02 Dec 2022 03:39:54 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:34880) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p11aK-0003su-Un for 59686@debbugs.gnu.org; Fri, 02 Dec 2022 03:39:53 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p11aF-0006WI-1c; Fri, 02 Dec 2022 03:39:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=qY0HqIGSmv6J95PCnZ8gKcYa+mFL+oR+PaFi1XXose8=; b=G0H3xWtmVd9dcO439rcd 2SsSlXY58SXsKUcsVuV+dqYBB2drsRmX8n9sWRVa1SsP0H5I8nkpr6B+yIPy8lcPFG9VUdObMU7zi PNs2cUBqmbbAo7GOfYI6qiebShbuUOkWVygkqb0vY/WPGrn+RNL8IjHGduDygo5GEVgMIan8DygZ5 ++SJvMUmf7Uyib4uHeaoOszZHeWWghgDk7W5KOIThGjv3taMaxe0EFNwoRQGqJB7R0tau5+HUtGvr /eS2JrVNYVZ99r4ASKl6Prt+5G0BAbEgsZXeBsbaLMcDujfmNxOy5QEARH18GxZ7hQ/4emRkFm9+f jSk171P/SFHpcg==; Original-Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p11aD-0004yV-WE; Fri, 02 Dec 2022 03:39:46 -0500 In-Reply-To: (bug-gnu-emacs@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:249720 Archived-At: > 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" > > >> // -*- c-ts -*- > >> int main() { > >> for (int i=0; i<10; ++i) { > >> foo(i); > >> } > >> > >> for (int i=0; > >> i<10; > >> ++i) { > >> foo(i); > >> } > >> } > > > >I see, that’s because the indent rule finds the BOL of the line where > >the "{" is on, and indents from there. Theo, WDYT? Does indent style > >fix this, or we should change the indent rules? > > > >Yuan > > 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_statement 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. > > 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 BOLs where important.