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#64329: 29.0.92; treesit/fill-paragraph syntax highlighting problem Date: Thu, 29 Jun 2023 08:10:05 +0300 Message-ID: <83ttuqua4y.fsf@gnu.org> References: <3031A934-37EC-497D-8A48-ECE7FD703B31@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="12890"; mail-complaints-to="usenet@ciao.gmane.io" Cc: brownts@troybrown.dev, 64329@debbugs.gnu.org To: Yuan Fu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jun 29 07:10:20 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 1qEjv9-0003DH-HS for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 29 Jun 2023 07:10:19 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qEjuu-0003jz-Ri; Thu, 29 Jun 2023 01:10:04 -0400 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 1qEjut-0003jg-1E for bug-gnu-emacs@gnu.org; Thu, 29 Jun 2023 01:10:03 -0400 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 1qEjus-0006Ok-L8 for bug-gnu-emacs@gnu.org; Thu, 29 Jun 2023 01:10:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qEjus-0003Nk-GD for bug-gnu-emacs@gnu.org; Thu, 29 Jun 2023 01:10:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 29 Jun 2023 05:10:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 64329 X-GNU-PR-Package: emacs Original-Received: via spool by 64329-submit@debbugs.gnu.org id=B64329.168801539612975 (code B ref 64329); Thu, 29 Jun 2023 05:10:02 +0000 Original-Received: (at 64329) by debbugs.gnu.org; 29 Jun 2023 05:09:56 +0000 Original-Received: from localhost ([127.0.0.1]:52043 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qEjui-0003N8-Bm for submit@debbugs.gnu.org; Thu, 29 Jun 2023 01:09:56 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:46222) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qEjud-0003Mq-60 for 64329@debbugs.gnu.org; Thu, 29 Jun 2023 01:09:50 -0400 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 1qEjuW-0006LA-2a; Thu, 29 Jun 2023 01:09:40 -0400 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=6wjpxosNrYKKTketGeyl5B5STIpFpvH8yL01SSKI0Gk=; b=rut70hhDz7AlYPZGkFpJ Hn01RFk672W0DZb62O8WR17E7G3Kk0N0ox4YsKw8SSKMLDJGAnfUaI7XlQbsUd0Blo2sN9rytYvTi 7YAc0hQJ6TdJ+/w3BYUTm7Ske6lL/QD4aB3rMN8xYfrNhvspgexisLYxujQQ0f/TbXpwcFbnQZPs5 WRHd6m1Bzfogtox8amMu2D5OPK2RIg+0YvgjymBBbFWArztI+yrCFBsSFcoX+6YW1zksoyhkYp7o1 bu1aKzNVh1YR+W2H0CyLAkz4QW7MRrmNoHLo3BfX+Xrywmw0DtP1YXpX+neFHjmjvs57DhLgybt+p 2EKyI6bLx2WjeA==; 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 1qEjuV-0004W9-IO; Thu, 29 Jun 2023 01:09:39 -0400 In-Reply-To: <3031A934-37EC-497D-8A48-ECE7FD703B31@gmail.com> (message from Yuan Fu on Wed, 28 Jun 2023 14:23:41 -0700) 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:264253 Archived-At: > From: Yuan Fu > Date: Wed, 28 Jun 2023 14:23:41 -0700 > Cc: 64329@debbugs.gnu.org, > Eli Zaretskii > > The culprit is the subst-char-in-region function used by the filling function. It has a branch: > > if (xxx) > { > replace_range (pos, pos + 1, string, ...); > } > else > { > for (i = 0; i < len; i++) *p++ = tostr[i]; > } > > I overlooked the else branch and thought subst-char-in-region always calls replace_range. replace_range notifies tree-sitter of the change it makes; but when subst-char-in-region manually replaces the text in the else branch, those edits are not notified to tree-sitter. > > Please see the attached patch. Eli, is it more preferable to add a subroutine in insdel.c that does what "for (i = 0; i < len; i++) *p++ = tostr[I];” does, plus calling treesit_record_change, and make subst-char-in-region call that subroutine? (This way editfns.c don’t need to include treesit.h and call treesit_record_change itself.) I'd prefer to install the patch you show on the emacs-29 branch, and then clean it up with a subroutine in insdel.c on master. We could also leave this on master without adding a subroutine: casefiddle.c already does something similar, so it's not like including treesit.h is known to cause trouble or something. Thanks.