From unknown Wed Jun 25 00:27:16 2025 X-Loop: help-debbugs@gnu.org Subject: bug#64329: 29.0.92; treesit/fill-paragraph syntax highlighting problem Resent-From: Troy Brown Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 28 Jun 2023 16:47:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 64329 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 64329@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.168797078626100 (code B ref -1); Wed, 28 Jun 2023 16:47:01 +0000 Received: (at submit) by debbugs.gnu.org; 28 Jun 2023 16:46:26 +0000 Received: from localhost ([127.0.0.1]:51521 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qEYJF-0006mt-79 for submit@debbugs.gnu.org; Wed, 28 Jun 2023 12:46:26 -0400 Received: from lists.gnu.org ([209.51.188.17]:55548) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qEYJA-0006mi-Cy for submit@debbugs.gnu.org; Wed, 28 Jun 2023 12:46:24 -0400 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 1qEYJA-0007wx-6P for bug-gnu-emacs@gnu.org; Wed, 28 Jun 2023 12:46:20 -0400 Received: from mail-lf1-f46.google.com ([209.85.167.46]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qEYJ8-000628-CL for bug-gnu-emacs@gnu.org; Wed, 28 Jun 2023 12:46:19 -0400 Received: by mail-lf1-f46.google.com with SMTP id 2adb3069b0e04-4fb8574a3a1so3457774e87.1 for ; Wed, 28 Jun 2023 09:46:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687970776; x=1690562776; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=NEC1NcKmJ//v629v4OB3PteJRrCqi2sTpVeLZerkWNQ=; b=Ejw899Ia4lN0VpMqd8Io0/qkgkOjVo/QUQflTvJUjaGNXDaOJDvbNwZOze8mN2Nx9G 1kas1ZPBRA+MdcNqAZoHMRTnS62w4Ms3lBAOV8bv206s+2JbTbnjVMh4ME2oPBDoBaQ7 ES8s4iJPLQvhEQncngdJ5uvBRGNA4uxm+Pf6R9Xh9l9ipvNoYNAl/9b/3EHUWbbyFnvj wmewkKM2RY7DhVdlHvCFvD+8jmktrC/Va9W+xWtNNtBLTZGu5XH3hW7F/kD3D1IBeDE9 PnelNERMB+tlZj9qfRwKyKsNd9i/rsDyLtzAlqfCJdrUA6YqljyNBbHTdt1aTLuKZYDJ teIw== X-Gm-Message-State: AC+VfDzILzZezYxh7jKUsG6UoWijIqxY039CmXdxTOQw9PU/LdDt9e9b 4jjM/ag5YzgkBBG35wfRJ6YRkDTMjbbJk2z6yb4= X-Google-Smtp-Source: ACHHUZ6ks4fhYPU59pQi6WeH7/tE1oSSPQpebv0RxrnUYnQpwaZhDhrbkzcACIRWCtLLRjegQJtHpg== X-Received: by 2002:a05:6512:ea7:b0:4f6:1433:fca0 with SMTP id bi39-20020a0565120ea700b004f61433fca0mr22954064lfb.0.1687970776024; Wed, 28 Jun 2023 09:46:16 -0700 (PDT) Received: from mail-lf1-f50.google.com (mail-lf1-f50.google.com. [209.85.167.50]) by smtp.gmail.com with ESMTPSA id z14-20020a19f70e000000b004fa35167729sm1855324lfe.159.2023.06.28.09.46.15 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 28 Jun 2023 09:46:15 -0700 (PDT) Received: by mail-lf1-f50.google.com with SMTP id 2adb3069b0e04-4fb8ede27eeso1867870e87.0 for ; Wed, 28 Jun 2023 09:46:15 -0700 (PDT) X-Received: by 2002:a05:6512:3985:b0:4fb:96ff:35d7 with SMTP id j5-20020a056512398500b004fb96ff35d7mr783531lfu.22.1687970775478; Wed, 28 Jun 2023 09:46:15 -0700 (PDT) MIME-Version: 1.0 From: Troy Brown Date: Wed, 28 Jun 2023 12:46:04 -0400 X-Gmail-Original-Message-ID: Message-ID: Content-Type: text/plain; charset="UTF-8" Received-SPF: pass client-ip=209.85.167.46; envelope-from=troy.s.brown@gmail.com; helo=mail-lf1-f46.google.com X-Spam_score_int: -13 X-Spam_score: -1.4 X-Spam_bar: - X-Spam_report: (-1.4 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.1 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.1 (--) I've noticed this problem on multiple tree-sitter major modes including c-ts-mode, c++-ts-mode, java-ts-mode, bash-ts-mode. I haven't tried others, but I suspect those might also suffer from this problem. The issue occurs when attempting to fill the paragraph of a comment block. The following comment block can be used as an example to reproduce the problem and happens with "emacs -Q" (assuming corresponding tree-sitter libraries are available). --8<---------------cut here---------------start------------->8--- // The quick brown fox jumps over the // lazy dog. // The quick brown fox jumps over the lazy dog. --8<---------------cut here---------------end--------------->8--- Switch to one of the tree-sitter modes (e.g., M-x java-ts-mode). Move point to the first line of the comment block above and then execute the fill-paragraph command (i.e., M-q). The text which is wrapped onto the first line of the comment block will be highlighted incorrectly. The results appear as if the comment delimiter was removed, fontification occurred, then the text was moved to the first line of the comment block and never refontified with the comment face. From unknown Wed Jun 25 00:27:16 2025 X-Loop: help-debbugs@gnu.org Subject: bug#64329: 29.0.92; treesit/fill-paragraph syntax highlighting problem Resent-From: Yuan Fu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 28 Jun 2023 21:25:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 64329 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Troy Brown Cc: Eli Zaretskii , 64329@debbugs.gnu.org Received: via spool by 64329-submit@debbugs.gnu.org id=B64329.168798744120101 (code B ref 64329); Wed, 28 Jun 2023 21:25:01 +0000 Received: (at 64329) by debbugs.gnu.org; 28 Jun 2023 21:24:01 +0000 Received: from localhost ([127.0.0.1]:51810 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qEcdt-0005E4-6l for submit@debbugs.gnu.org; Wed, 28 Jun 2023 17:24:01 -0400 Received: from mail-pl1-f175.google.com ([209.85.214.175]:45135) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qEcdr-0005Dn-Hc for 64329@debbugs.gnu.org; Wed, 28 Jun 2023 17:24:00 -0400 Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-1b7dd061e9aso3276055ad.2 for <64329@debbugs.gnu.org>; Wed, 28 Jun 2023 14:23:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687987433; x=1690579433; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:from:to:cc:subject:date:message-id:reply-to; bh=U+xV5ocmnFe44p5zb6rWOkGMFqcf6i/WWHqTJfxZxxk=; b=OL4s9+M5RxrRd5+1Wu8W/9OYvp+9g1HdufNM0WC8EelGV7Tcqbtc+IFZBmvm8s66eq EsCLRDVOSWK80nvCZW/sb+VelWKIH+TJCDYVqy0VtgyQz82Xw6UIN6AN7Ng0TzGnQQzl LCTzva8vsAM2vTEswL0MJBYh24U0qc0pJmx3O+Jg2Rp6kmLDGPK0m5Qf1vxl08RFdsDx k5R7EbfSU7IbbBHesaUxBCODVCyRmmh50pBhNGTAJjpL+k9Pwb0H3uCUOl+tXhvz3yU+ wDm0bS4O0UvAwjOs5EN60D3H1hmfDqxyjX6muweUvflAlOVxUbyXGI/zyvVUj5cyM1Sr JzAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687987433; x=1690579433; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=U+xV5ocmnFe44p5zb6rWOkGMFqcf6i/WWHqTJfxZxxk=; b=N3WaG33sS6mkIOVx5Va7RXCw+uGhxL4/VQTB54mHqhUM8/KPXDy56nkVN1KFK9AHgi BgRrbE3rT+8uTRtirmg0izsUzyUzxnE41ZuVadnnu/+/7X3AIm4zXB5D2+/9gycme9xO y8vzF7XialU9IzigTaDoExZXlsFQraH+iWi04ELbGjH2Q/eYUH1XYpx8ZrD20pgy0EJS ukpueevcP9ClKc18zoOysDnOJxWz8RwsMQ3MoBMT8oO+zlbrzC5RthiJsBVvFoM3NLNz fpw4wyMY7qUME71GJ/YHxksq/jOd7iIO1mjTFim560ZjINO8RUnn5HGAhp5RrKwQnYk7 IFPg== X-Gm-Message-State: AC+VfDwxQjOPSA0U0Bt4ECRkNJRftq+UZgfmAx+zKdlIWel6x2CSrN2r ymBuuGmUBzRGHwql1du77qk= X-Google-Smtp-Source: ACHHUZ6AO47Iqab9Bj1vlf1Xo/9zYDMAuEiYb7t7vssiR5BMw2WQy8lSEwckuBRPVxVoh8a+G3R4Ng== X-Received: by 2002:a17:902:9a05:b0:1b1:8e8b:7f6c with SMTP id v5-20020a1709029a0500b001b18e8b7f6cmr11276121plp.16.1687987433521; Wed, 28 Jun 2023 14:23:53 -0700 (PDT) Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id i1-20020a1709026ac100b001b6a27dff99sm8079027plt.159.2023.06.28.14.23.52 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Jun 2023 14:23:53 -0700 (PDT) From: Yuan Fu Message-Id: <3031A934-37EC-497D-8A48-ECE7FD703B31@gmail.com> Content-Type: multipart/mixed; boundary="Apple-Mail=_3F520BE8-3FFA-405A-8D27-8D5D65E104C1" Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.600.7\)) Date: Wed, 28 Jun 2023 14:23:41 -0700 In-Reply-To: References: X-Mailer: Apple Mail (2.3731.600.7) X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --Apple-Mail=_3F520BE8-3FFA-405A-8D27-8D5D65E104C1 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Jun 28, 2023, at 9:46 AM, Troy Brown wrote: >=20 > I've noticed this problem on multiple tree-sitter major modes = including > c-ts-mode, c++-ts-mode, java-ts-mode, bash-ts-mode. I haven't tried > others, but I suspect those might also suffer from this problem. >=20 > The issue occurs when attempting to fill the paragraph of a comment > block. The following comment block can be used as an example to > reproduce the problem and happens with "emacs -Q" (assuming > corresponding tree-sitter libraries are available). >=20 > --8<---------------cut here---------------start------------->8--- > // The quick brown fox jumps over the > // lazy dog. > // The quick brown fox jumps over the lazy dog. > --8<---------------cut here---------------end--------------->8--- >=20 > Switch to one of the tree-sitter modes (e.g., M-x java-ts-mode). Move > point to the first line of the comment block above and then execute = the > fill-paragraph command (i.e., M-q). >=20 > The text which is wrapped onto the first line of the comment block = will > be highlighted incorrectly. The results appear as if the comment > delimiter was removed, fontification occurred, then the text was moved > to the first line of the comment block and never refontified with the > comment face. Thank you very much! It=E2=80=99s funny that how long this went under = the radar, presumably because we always use block comment. 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 =3D 0; i < len; i++) *p++ =3D 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 =3D 0; i < len; i++) *p++ = =3D tostr[I];=E2=80=9D does, plus calling treesit_record_change, and = make subst-char-in-region call that subroutine? (This way editfns.c = don=E2=80=99t need to include treesit.h and call treesit_record_change = itself.) Yuan --Apple-Mail=_3F520BE8-3FFA-405A-8D27-8D5D65E104C1 Content-Disposition: attachment; filename=notify.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="notify.patch" Content-Transfer-Encoding: quoted-printable =46rom=20ab94e738fb0137f1296921232cbd65046c11022f=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20Yuan=20Fu=20=0ADate:=20Wed,=20= 28=20Jun=202023=2014:16:52=20-0700=0ASubject:=20[PATCH]=20Call=20= treesit_record_change=20in=20subst-char-in-region=0A=20(bug#64329)=0A=0A= *=20src/editfns.c=20(Fsubst_char_in_region):=20Call=20= treesit_record_change=20in=0Athe=20else=20branch.=0A---=0A=20= src/editfns.c=20|=2013=20+++++++++++++=0A=201=20file=20changed,=2013=20= insertions(+)=0A=0Adiff=20--git=20a/src/editfns.c=20b/src/editfns.c=0A= index=20d02cce4aef3..0cbeefb3262=20100644=0A---=20a/src/editfns.c=0A+++=20= b/src/editfns.c=0A@@=20-55,6=20+55,11=20@@=20Copyright=20(C)=201985-2023=20= Free=20Software=20Foundation,=20Inc.=0A=20#ifdef=20WINDOWSNT=0A=20#=20= include=20"w32common.h"=0A=20#endif=0A+=0A+#ifdef=20HAVE_TREE_SITTER=0A= +#include=20"treesit.h"=0A+#endif=0A+=0A=20static=20void=20= update_buffer_properties=20(ptrdiff_t,=20ptrdiff_t);=0A=20static=20= Lisp_Object=20styled_format=20(ptrdiff_t,=20Lisp_Object=20*,=20bool);=0A=20= =0A@@=20-2391,6=20+2396,14=20@@=20#define=20COMBINING_BOTH=20= (COMBINING_BEFORE=20|=20COMBINING_AFTER)=0A=20=09=20=20=20=20=20=20if=20= (NILP=20(noundo))=0A=20=09=09record_change=20(pos,=201);=0A=20=09=20=20=20= =20=20=20for=20(i=20=3D=200;=20i=20<=20len;=20i++)=20*p++=20=3D=20= tostr[i];=0A+=0A+#ifdef=20HAVE_TREE_SITTER=0A+=09=20=20=20=20=20=20/*=20= In=20the=20previous=20branch,=20replace_range()=20notifies=0A+=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20changes=20to=20tree-sitter,=20but=20= in=20this=20branch,=20we=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20modified=20buffer=20content=20manually,=20so=20we=20need=20to=0A+=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20notify=20tree-sitter=20= manually.=20=20*/=0A+=09=20=20=20=20=20=20treesit_record_change=20= (pos_byte,=20pos_byte=20+=20len,=20pos_byte=20+=20len);=0A+#endif=0A=20=09= =20=20=20=20}=0A=20=09=20=20last_changed=20=3D=20=20pos=20+=201;=0A=20=09= }=0A--=20=0A2.33.1=0A=0A= --Apple-Mail=_3F520BE8-3FFA-405A-8D27-8D5D65E104C1-- From unknown Wed Jun 25 00:27:16 2025 X-Loop: help-debbugs@gnu.org Subject: bug#64329: 29.0.92; treesit/fill-paragraph syntax highlighting problem Resent-From: Yuan Fu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 29 Jun 2023 00:18:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 64329 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Troy Brown Cc: Eli Zaretskii , 64329@debbugs.gnu.org Received: via spool by 64329-submit@debbugs.gnu.org id=B64329.16879978595363 (code B ref 64329); Thu, 29 Jun 2023 00:18:01 +0000 Received: (at 64329) by debbugs.gnu.org; 29 Jun 2023 00:17:39 +0000 Received: from localhost ([127.0.0.1]:51867 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qEfLu-0001OR-Ne for submit@debbugs.gnu.org; Wed, 28 Jun 2023 20:17:39 -0400 Received: from mail-pf1-f178.google.com ([209.85.210.178]:44255) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qEfLp-0001O9-EX for 64329@debbugs.gnu.org; Wed, 28 Jun 2023 20:17:37 -0400 Received: by mail-pf1-f178.google.com with SMTP id d2e1a72fcca58-666e3b15370so113196b3a.0 for <64329@debbugs.gnu.org>; Wed, 28 Jun 2023 17:17:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687997847; x=1690589847; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:from:to:cc:subject:date:message-id:reply-to; bh=l5lOTss/DI067AEiaIKUMZBoR9yfh3nUtOA7uH2PGRo=; b=JhFKnbPchOINUZem6AlUOeLqivEjFwaWtinbpRKt1ZlD9SbPEaba7AuzsfxhPHnd5r gIJmN3zDA0Hq3JPV67Cw9uhA8ZFdURsJybtCne4JV7DNrwRYnQmwGQqrA3HjdUOXd67n L1xdPhsckFY3s02FLAyy7sO55qqAutjusLQT4//GJS0QQ2n/hEBBvGs5YPmv56b9TRWp 70gATAGOeMtGDYtubbLUQ++yoXbW39G9pLYrXFJBZnPufSAnw2fwVJaghzf/stfhHaYz ux73PIqKwwPlOXp7t4s+RN3NC3EHQcfoYZ6gdDKYhdVqQMnr9wRxWMb0iiHvJDaOBAWw Rgrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687997847; x=1690589847; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=l5lOTss/DI067AEiaIKUMZBoR9yfh3nUtOA7uH2PGRo=; b=UsHkH/pUjSSoqUaW23lqnAulvzOEyK3Hg2z4h7AECJFinT+u6xv7OlWuIYgrTHdcAD BMktWzWCglqoQPVDzBI+tCeS8deE2o8bFl8n3JP0mylI627cLnuokm5C780LefN6P3H4 XvWd2t/zIJNvkR/DfRs710X9nZGnwMBw+UkOkraJBn7SkaiIN9/Cpdh+GbheiiTByy3a /BQnSfq2YG2+Hn3iZ0ifvGxZqYWc5wYo6pqGAXf/ggUSGIGCUWax676H9jxHORLkwHG4 AxZwYo+zFJCCQTmh4Mcme9J0AoUB2OK6Y9H6anb8GCvQyrcdFdYychUfQmBNoAF44EXo O8Zw== X-Gm-Message-State: AC+VfDwcE0cY9KZQEemyRuiEWoz6qCxHTzwRbUJOE7kBnqfIfD0nAjkK WGgZmIeln0i/4EPKHK/KPCo= X-Google-Smtp-Source: ACHHUZ61Cs+JNe7rSsyCJ2Hn+MjqRimZ/A+E6WWPus8mByjtG0QA7z6LK+HcyrUYUtGgNz3rezybcw== X-Received: by 2002:a05:6a20:8f26:b0:12a:40d7:3fcf with SMTP id b38-20020a056a208f2600b0012a40d73fcfmr6177092pzk.24.1687997847165; Wed, 28 Jun 2023 17:17:27 -0700 (PDT) Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id j18-20020a62e912000000b00660d80087a8sm7454639pfh.187.2023.06.28.17.17.25 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Jun 2023 17:17:25 -0700 (PDT) From: Yuan Fu Message-Id: <14493480-9226-4AB1-A313-E4E2D61AB0BD@gmail.com> Content-Type: multipart/mixed; boundary="Apple-Mail=_447F6C4E-279C-4768-9A7C-C1284E9B41AC" Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.600.7\)) Date: Wed, 28 Jun 2023 17:17:14 -0700 In-Reply-To: <3031A934-37EC-497D-8A48-ECE7FD703B31@gmail.com> References: <3031A934-37EC-497D-8A48-ECE7FD703B31@gmail.com> X-Mailer: Apple Mail (2.3731.600.7) X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --Apple-Mail=_447F6C4E-279C-4768-9A7C-C1284E9B41AC Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Jun 28, 2023, at 2:23 PM, Yuan Fu wrote: >=20 >=20 >=20 >> On Jun 28, 2023, at 9:46 AM, Troy Brown = wrote: >>=20 >> I've noticed this problem on multiple tree-sitter major modes = including >> c-ts-mode, c++-ts-mode, java-ts-mode, bash-ts-mode. I haven't tried >> others, but I suspect those might also suffer from this problem. >>=20 >> The issue occurs when attempting to fill the paragraph of a comment >> block. The following comment block can be used as an example to >> reproduce the problem and happens with "emacs -Q" (assuming >> corresponding tree-sitter libraries are available). >>=20 >> --8<---------------cut here---------------start------------->8--- >> // The quick brown fox jumps over the >> // lazy dog. >> // The quick brown fox jumps over the lazy dog. >> --8<---------------cut here---------------end--------------->8--- >>=20 >> Switch to one of the tree-sitter modes (e.g., M-x java-ts-mode). = Move >> point to the first line of the comment block above and then execute = the >> fill-paragraph command (i.e., M-q). >>=20 >> The text which is wrapped onto the first line of the comment block = will >> be highlighted incorrectly. The results appear as if the comment >> delimiter was removed, fontification occurred, then the text was = moved >> to the first line of the comment block and never refontified with the >> comment face. >=20 > Thank you very much! It=E2=80=99s funny that how long this went under = the radar, presumably because we always use block comment. >=20 > The culprit is the subst-char-in-region function used by the filling = function. It has a branch: >=20 > if (xxx) > { > replace_range (pos, pos + 1, string, ...); > } > else > { > for (i =3D 0; i < len; i++) *p++ =3D tostr[i]; > } >=20 > 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. Prompted by this, I went over all the functions that calls = signal_after_change again, and found two other editfns.c functions that = are missing calls to treesit_record_change. Please see the attached = patches that follows the previous one. Sorry for the overlook. I believe = I=E2=80=99ve found all places that needs to call treesit_record_change = now. > Please see the attached patch. Eli, is it more preferable to add a = subroutine in insdel.c that does what "for (i =3D 0; i < len; i++) *p++ = =3D tostr[I];=E2=80=9D does, plus calling treesit_record_change, and = make subst-char-in-region call that subroutine? (This way editfns.c = don=E2=80=99t need to include treesit.h and call treesit_record_change = itself.) Since now there are three functions in editfns.c that needs to call = treesit_record_change, we might as well just include treesit.h and call = treesit_record_change directly. Yuan --Apple-Mail=_447F6C4E-279C-4768-9A7C-C1284E9B41AC Content-Disposition: attachment; filename=add-two-other-missing-calls.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="add-two-other-missing-calls.patch" Content-Transfer-Encoding: quoted-printable =46rom=20a09bfd309ffbb4e33df3c1a850193dc20b93af1c=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20Yuan=20Fu=20=0ADate:=20Wed,=20= 28=20Jun=202023=2017:03:19=20-0700=0ASubject:=20[PATCH=201/2]=20Add=20= missing=20calls=20to=20treesit_record_change=20in=20editfns.c=0A=0AThese=20= should=20be=20all=20that=20are=20missing.=20=20See=20the=20next=20commit=20= for=20detail.=0A=0A*=20src/editfns.c=20(Ftranslate_region_internal):=0A= (Ftranspose_regions):=20Call=20treesit_record_change.=0A---=0A=20= src/editfns.c=20|=2016=20++++++++++++++++=0A=201=20file=20changed,=2016=20= insertions(+)=0A=0Adiff=20--git=20a/src/editfns.c=20b/src/editfns.c=0A= index=200cbeefb3262..a1e48daf6c6=20100644=0A---=20a/src/editfns.c=0A+++=20= b/src/editfns.c=0A@@=20-2603,6=20+2603,15=20@@=20DEFUN=20= ("translate-region-internal",=20Ftranslate_region_internal,=0A=20=09=09=20= =20=20=20*p++=20=3D=20*str++;=0A=20=09=09=20=20signal_after_change=20= (pos,=201,=201);=0A=20=09=09=20=20update_compositions=20(pos,=20pos=20+=20= 1,=20CHECK_BORDER);=0A+=0A+#ifdef=20HAVE_TREE_SITTER=0A+=09=09=20=20/*=20= In=20the=20previous=20branch,=20replace_range()=20notifies=0A+=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20changes=20to=20= tree-sitter,=20but=20in=20this=20branch,=20we=0A+=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20modified=20buffer=20content=20= manually,=20so=20we=20need=20to=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20notify=20tree-sitter=20manually.=20=20*/=0A+=09=09= =20=20treesit_record_change=20(pos_byte,=20pos_byte=20+=20len,=0A+=09=09=09= =09=09=20pos_byte=20+=20len);=0A+#endif=0A=20=09=09}=0A=20=09=20=20=20=20= =20=20characters_changed++;=0A=20=09=20=20=20=20}=0A@@=20-4776,6=20= +4785,13=20@@=20DEFUN=20("transpose-regions",=20Ftranspose_regions,=20= Stranspose_regions,=204,=205,=0A=20=20=20=20=20=20=20= adjust_markers_bytepos=20(start1,=20start1_byte,=20end2,=20end2_byte,=20= 0);=0A=20=20=20=20=20}=0A=20=0A+#ifdef=20HAVE_TREE_SITTER=0A+=20=20/*=20= I=20don't=20think=20it's=20common=20to=20transpose=20two=20far-apart=20= regions,=20so=0A+=20=20=20=20=20amalgamating=20the=20edit=20into=20one=20= should=20be=20fine.=20=20This=20is=20what=20the=0A+=20=20=20=20=20= signal_after_change=20below=20does,=20too.=20=20*/=0A+=20=20= treesit_record_change=20(start1_byte,=20end2_byte,=20end2_byte);=0A= +#endif=0A+=0A=20=20=20signal_after_change=20(start1,=20end2=20-=20= start1,=20end2=20-=20start1);=0A=20=20=20return=20Qnil;=0A=20}=0A--=20=0A= 2.33.1=0A=0A=0A=46rom=2094758fb0e11ce4dd763cd50990828879f9c41b19=20Mon=20= Sep=2017=2000:00:00=202001=0AFrom:=20Yuan=20Fu=20=0A= Date:=20Wed,=2028=20Jun=202023=2017:05:29=20-0700=0ASubject:=20[PATCH=20= 2/2]=20;=20*=20admin/notes/tree-sitter/treesit_record_change:=0A=20= Update.=0A=0A---=0A=20admin/notes/tree-sitter/treesit_record_change=20|=20= 180=20+++++++++++++++++-=0A=201=20file=20changed,=20174=20insertions(+),=20= 6=20deletions(-)=0A=0Adiff=20--git=20= a/admin/notes/tree-sitter/treesit_record_change=20= b/admin/notes/tree-sitter/treesit_record_change=0Aindex=20= 0dc6491e2d1..e80df4adfa7=20100644=0A---=20= a/admin/notes/tree-sitter/treesit_record_change=0A+++=20= b/admin/notes/tree-sitter/treesit_record_change=0A@@=20-3,10=20+3,10=20= @@=20NOTES=20ON=20TREESIT_RECORD_CHANGE=0A=20It=20is=20vital=20that=20= Emacs=20informs=20tree-sitter=20of=20every=20change=20made=20to=20the=0A=20= buffer,=20lest=20tree-sitter's=20parse=20tree=20would=20be=20= corrupted/out=20of=20sync.=0A=20=0A-All=20buffer=20changes=20in=20Emacs=20= are=20made=20through=20functions=20in=20insdel.c=0A-(and=20= casefiddle.c),=20I=20augmented=20functions=20in=20those=20files=20with=20= calls=20to=0A-treesit_record_change.=20=20Below=20is=20a=20manifest=20of=20= all=20the=20relevant=0A-functions=20in=20insdel.c=20as=20of=20Emacs=20= 29:=0A+Almost=20all=20buffer=20changes=20in=20Emacs=20are=20made=20= through=20functions=20in=0A+insdel.c=20(see=20below=20for=20exceptions),=20= I=20augmented=20functions=20in=20insdel.c=0A+with=20calls=20to=20= treesit_record_change.=20=20Below=20is=20a=20manifest=20of=20all=20the=0A= +relevant=20functions=20in=20insdel.c=20as=20of=20Emacs=2029:=0A=20=0A=20= Function=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20Calls=0A=20= ----------------------------------------------------------------------=0A= @@=20-43,8=20+43,176=20@@=20insert_from_buffer=20but=20not=20= insert_from_buffer_1.=20=20I=20also=20left=20a=0A=20reminder=20comment.=0A= =20=0A=20=0A-As=20for=20casefiddle.c,=20do_casify_unibyte_region=20and=0A= +EXCEPTIONS=0A+=0A+=0A+There=20are=20a=20couple=20of=20functions=20that=20= replaces=20characters=20in-place=0A+rather=20than=20insert/delete.=20= They=20are=20in=20casefiddle.c=20and=20editfns.c.=0A+=0A+In=20= casefiddle.c,=20do_casify_unibyte_region=20and=0A=20= do_casify_multibyte_region=20modifies=20buffer,=20but=20they=20are=20= static=0A=20functions=20and=20are=20called=20by=20casify_region,=20which=20= calls=0A=20treesit_record_change.=20=20Other=20higher-level=20functions=20= calls=0A-casify_region=20to=20do=20the=20work.=0A\=20No=20newline=20at=20= end=20of=20file=0A+casify_region=20to=20do=20the=20work.=0A+=0A+In=20= editfns.c,=20subst-char-in-region=20and=20translate-region-internal=20= might=0A+replace=20characters=20in-place,=20I=20made=20them=20to=20call=0A= +treesit_record_change.=20=20transpose-regions=20uses=20memcpy=20to=20= move=20text=0A+around,=20it=20calls=20treesit_record_change=20too.=0A+=0A= +I=20found=20these=20exceptions=20by=20grepping=20for=20= signal_after_change=20and=0A+checking=20each=20caller=20manually.=20=20= Below=20is=20all=20the=20result=20as=20of=20Emacs=2029=0A+and=20some=20= comment=20for=20each=20one.=20=20Readers=20can=20use=0A+=0A= +(highlight-regexp=20"^[^[:space:]]+?\\.c:[[:digit:]]+:[^z-a]+?$"=20= 'highlight)=0A+=0A+to=20make=20things=20easier=20to=20read.=0A+=0A+grep=20= [...]=20--color=3Dauto=20-i=20--directories=3Dskip=20-nH=20--null=20-e=20= signal_after_change=20*.c=0A+=0A+callproc.c:789:=20=20=20=20=20=20=20=20=20= =20=20=20=20calling=20prepare_to_modify_buffer=20and=20= signal_after_change.=0A+callproc.c:793:=20=20=20=20=20=20=20=20=20=20=20=20= =20is=20one=20call=20to=20signal_after_change=20in=20each=20of=20the=0A= +callproc.c:800:=20=20=20=20=20=20=20=20=20=20=20=20=20= signal_after_change=20hasn't.=20=20A=20continue=20statement=0A= +callproc.c:804:=20=20=20=20=20=20=20=20=20=20=20=20=20again,=20and=20= this=20time=20signal_after_change=20gets=20called,=0A+=0A+Not=20code.=0A= +=0A+callproc.c:820:=20=20=20=20=20=20=20=20=20=20=20=20=20=20= signal_after_change=20(PT=20-=20nread,=200,=20nread);=0A+callproc.c:863:=20= =20=20=20=20=20=20=20=20=20=20=20=20=20signal_after_change=20(PT=20-=20= process_coding.produced_char,=0A+=0A+Both=20are=20called=20in=20= call-process.=20=20I=20don=E2=80=99t=20think=20we=E2=80=99ll=20ever=20= use=0A+tree-sitter=20in=20call-process=E2=80=99s=20stdio=20buffer,=20= right?=20=20I=20didn=E2=80=99t=20check=0A+line-by-line,=20but=20it=20= seems=20to=20only=20use=20insert_1_both=20and=20del_range_2.=0A+=0A= +casefiddle.c:558:=20=20=20=20=20=20signal_after_change=20(start,=20end=20= -=20start=20-=20added,=20end=20-=20start);=0A+=0A+Called=20in=20= casify-region,=20calls=20treesit_record_change.=0A+=0A+decompress.c:195:=20= =20=20=20=20=20signal_after_change=20(data->orig,=20data->start=20-=20= data->orig,=0A+=0A+Called=20in=20unwind_decompress,=20uses=20= del_range_2,=20insdel=20function.=0A+=0A+decompress.c:334:=20=20= signal_after_change=20(istart,=20iend=20-=20istart,=20= unwind_data.nbytes);=0A+=0A+Called=20in=20zlib-decompress-region,=20uses=20= del_range_2,=20insdel=20function.=0A+=0A+editfns.c:2139:=20=20=20=20=20=20= signal_after_change=20(BEGV,=20size_a,=20ZV=20-=20BEGV);=0A+=0A+Called=20= in=20replace-buffer-contents,=20which=20calls=20del_range=20and=0A= +Finsert_buffer_substring,=20both=20are=20ok.=0A+=0A+editfns.c:2416:=20=20= =20=20=20=20signal_after_change=20(changed,=0A+=0A+Called=20in=20= subst-char-in-region,=20which=20either=20calls=20replace_range=20(a=0A= +insdel=20function)=20or=20modifies=20buffer=20content=20by=20itself=20= (need=20to=20call=0A+treesit_record_change).=0A+=0A+editfns.c:2544:=09=20= =20=20=20=20=20/*=20Reload=20as=20signal_after_change=20in=20last=20= iteration=20may=20GC.=20=20*/=0A+=0A+Not=20code.=0A+=0A+editfns.c:2604:=09= =09=20=20signal_after_change=20(pos,=201,=201);=0A+=0A+Called=20in=20= translate-region-internal,=20which=20has=20three=20cases:=0A+=0A+if=20= (nc=20!=3D=20oc=20&&=20nc=20>=3D=200)=20{=0A+=20=20if=20(len=20!=3D=20= str_len)=20{=0A+=09replace_range()=0A+=20=20}=20else=20{=0A+=09while=20= (str_len--=20>=200)=0A+=09=20=20*p++=20=3D=20*str++;=0A+=20=20}=0A+}=0A= +else=20if=20(nc=20<=200)=20{=0A+=20=20replace_range()=0A+}=0A+=0A= +replace_range=20is=20ok,=20but=20in=20the=20case=20where=20it=20= manually=20modifies=20buffer=0A+content,=20it=20needs=20to=20call=20= treesit_record_change.=0A+=0A+editfns.c:4779:=20=20signal_after_change=20= (start1,=20end2=20-=20start1,=20end2=20-=20start1);=0A+=0A+Called=20in=20= transpose-regions.=20=20It=20just=20uses=20memcpy=E2=80=99s=20and=20= doesn=E2=80=99t=20use=0A+insdel=20functions;=20needs=20to=20call=20= treesit_record_change.=0A+=0A+fileio.c:4825:=20=20=20=20=20=20= signal_after_change=20(PT,=200,=20inserted);=0A+=0A+Called=20in=20= insert_file_contents.=20=20Uses=20insert_1_both=20(very=20first=20in=20= the=0A+function);=20del_range_1=20and=20del_range_byte=20(the=20= optimized=20way=20to=0A+implement=20replace=20when=20decoding=20isn=E2=80=99= t=20needed);=20del_range_byte=20and=0A+insert_from_buffer=20(the=20= optimized=20way=20used=20when=20decoding=20is=20needed);=0A= +decode_coding_gap=20or=20insert_from_gap_1=20(I=E2=80=99m=20not=20sure=20= the=20condition=20for=0A+this,=20but=20anyway=20it=E2=80=99s=20safe).=20=20= The=20function=20also=20calls=20memcpy=20and=0A+memmove,=20but=20they=20= are=20irrelevant:=20memcpy=20is=20used=20for=20decoding,=20and=0A= +memmove=20is=20moving=20stuff=20inside=20the=20gap=20for=20= decode_coding_gap.=0A+=0A+I=E2=80=99d=20love=20someone=20to=20verify=20= this=20function,=20since=20it=E2=80=99s=20so=20complicated=0A+and=20= large,=20but=20from=20what=20I=20can=20tell=20it=E2=80=99s=20safe.=0A+=0A= +fns.c:3998:=20=20signal_after_change=20(XFIXNAT=20(beg),=200,=20= inserted_chars);=0A+=0A+Called=20in=20base64-decode-region,=20uses=20= insert_1_both=20and=20del_range_both,=0A+safe.=0A+=0A+insdel.c:681:=20=20= =20=20=20=20signal_after_change=20(opoint,=200,=20len);=0A+insdel.c:696:=20= =20=20=20=20=20signal_after_change=20(opoint,=200,=20len);=0A= +insdel.c:741:=20=20=20=20=20=20signal_after_change=20(opoint,=200,=20= len);=0A+insdel.c:757:=20=20=20=20=20=20signal_after_change=20(opoint,=20= 0,=20len);=0A+insdel.c:976:=20=20signal_after_change=20(opoint,=200,=20= PT=20-=20opoint);=0A+insdel.c:996:=20=20signal_after_change=20(opoint,=20= 0,=20PT=20-=20opoint);=0A+insdel.c:1187:=20=20signal_after_change=20= (opoint,=200,=20PT=20-=20opoint);=0A+insdel.c:1412:=20=20=20= signal_after_change.=20=20*/=0A+insdel.c:1585:=20=20=20=20=20=20= signal_after_change=20(from,=20nchars_del,=20GPT=20-=20from);=0A= +insdel.c:1600:=20=20=20prepare_to_modify_buffer=20and=20never=20call=20= signal_after_change.=0A+insdel.c:1603:=20=20=20region=20once.=20=20Apart=20= from=20signal_after_change,=20any=20caller=20of=20this=0A+insdel.c:1747:=20= =20signal_after_change=20(from,=20to=20-=20from,=200);=0A+insdel.c:1789:=20= =20signal_after_change=20(from,=20to=20-=20from,=200);=0A+insdel.c:1833:=20= =20signal_after_change=20(from,=20to=20-=20from,=200);=0A= +insdel.c:2223:signal_after_change=20(ptrdiff_t=20charpos,=20ptrdiff_t=20= lendel,=20ptrdiff_t=20lenins)=0A+insdel.c:2396:=20=20signal_after_change=20= (begpos,=20endpos=20-=20begpos=20-=20change,=20endpos=20-=20begpos);=0A+=0A= +I=E2=80=99ve=20checked=20all=20insdel=20functions.=20=20We=20can=20= assume=20insdel=20functions=20are=0A+all=20safe.=0A+=0A+json.c:790:=20=20= signal_after_change=20(PT,=200,=20inserted);=0A+=0A+Called=20in=20= json-insert,=20calls=20either=20decode_coding_gap=20or=0A= +insert_from_gap_1,=20both=20are=20safe.=20Calls=20memmove=20but=20= it=E2=80=99s=20for=0A+decode_coding_gap.=0A+=0A+keymap.c:2873:=09=20=20=20= =20/*=20Insert=20calls=20signal_after_change=20which=20may=20GC.=20=20*/=0A= +=0A+Not=20code.=0A+=0A+print.c:219:=20=20=20=20=20=20= signal_after_change=20(PT=20-=20print_buffer.pos,=200,=20= print_buffer.pos);=0A+=0A+Called=20in=20print_finish,=20calls=20= copy_text=20and=20insert_1_both,=20safe.=0A+=0A+process.c:6365:=09=20= process=20buffer=20is=20changed=20in=20the=20signal_after_change=20= above.=0A+search.c:2763:=20=20=20=20=20(see=20signal_before_change=20and=20= signal_after_change).=20=20Try=20to=20error=0A+=0A+Not=20code.=0A+=0A= +search.c:2777:=20=20signal_after_change=20(sub_start,=20sub_end=20-=20= sub_start,=20SCHARS=20(newtext));=0A+=0A+Called=20in=20replace_match.=20=20= Calls=20replace_range,=20upcase-region,=0A+upcase-initials-region=20= (both=20calls=20casify_region=20in=20the=20end),=20safe.=0A+Calls=20= memcpy=20but=20it=E2=80=99s=20for=20string=20manipulation.=0A+=0A= +textprop.c:1261:=09=09signal_after_change=20(XFIXNUM=20(start),=20= XFIXNUM=20(end)=20-=20XFIXNUM=20(start),=0A+textprop.c:1272:=09=09= signal_after_change=20(XFIXNUM=20(start),=20XFIXNUM=20(end)=20-=20= XFIXNUM=20(start),=0A+textprop.c:1283:=09=20=20=20=20signal_after_change=20= (XFIXNUM=20(start),=20XFIXNUM=20(end)=20-=20XFIXNUM=20(start),=0A= +textprop.c:1458:=20=20=20=20signal_after_change=20(XFIXNUM=20(start),=20= XFIXNUM=20(end)=20-=20XFIXNUM=20(start),=0A+textprop.c:1652:=09=09= signal_after_change=20(XFIXNUM=20(start),=20XFIXNUM=20(end)=20-=20= XFIXNUM=20(start),=0A+textprop.c:1661:=09=09signal_after_change=20= (XFIXNUM=20(start),=20XFIXNUM=20(end)=20-=20XFIXNUM=20(start),=0A= +textprop.c:1672:=09=20=20=20=20signal_after_change=20(XFIXNUM=20= (start),=20XFIXNUM=20(end)=20-=20XFIXNUM=20(start),=0A+textprop.c:1750:=20= =20=20=20=20before=20changes=20are=20made=20and=20signal_after_change=20= when=20we=20are=20done.=0A+textprop.c:1752:=20=20=20=20=20and=20call=20= signal_after_change=20before=20returning=20if=20MODIFIED.=20*/=0A= +textprop.c:1764:=09=09=20=20=20=20signal_after_change=20(XFIXNUM=20= (start),=0A+textprop.c:1778:=09=09signal_after_change=20(XFIXNUM=20= (start),=20XFIXNUM=20(end)=20-=20XFIXNUM=20(start),=0A+textprop.c:1791:=09= =09signal_after_change=20(XFIXNUM=20(start),=20XFIXNUM=20(end)=20-=20= XFIXNUM=20(start),=0A+textprop.c:1810:=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20signal_after_change=20(XFIXNUM=20(start),=0A+=0A+We=20= don=E2=80=99t=20care=20about=20text=20property=20changes.=0A+=0A+Grep=20= finished=20with=2051=20matches=20found=20at=20Wed=20Jun=2028=2015:12:23=0A= --=20=0A2.33.1=0A=0A= --Apple-Mail=_447F6C4E-279C-4768-9A7C-C1284E9B41AC Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii --Apple-Mail=_447F6C4E-279C-4768-9A7C-C1284E9B41AC-- From unknown Wed Jun 25 00:27:16 2025 X-Loop: help-debbugs@gnu.org Subject: bug#64329: 29.0.92; treesit/fill-paragraph syntax highlighting problem 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 X-GNU-PR-Keywords: To: Yuan Fu Cc: brownts@troybrown.dev, 64329@debbugs.gnu.org Received: via spool by 64329-submit@debbugs.gnu.org id=B64329.168801539612975 (code B ref 64329); Thu, 29 Jun 2023 05:10:02 +0000 Received: (at 64329) by debbugs.gnu.org; 29 Jun 2023 05:09:56 +0000 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 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 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==; 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 Date: Thu, 29 Jun 2023 08:10:05 +0300 Message-Id: <83ttuqua4y.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: <3031A934-37EC-497D-8A48-ECE7FD703B31@gmail.com> (message from Yuan Fu on Wed, 28 Jun 2023 14:23:41 -0700) References: <3031A934-37EC-497D-8A48-ECE7FD703B31@gmail.com> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > 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. From unknown Wed Jun 25 00:27:16 2025 X-Loop: help-debbugs@gnu.org Subject: bug#64329: 29.0.92; treesit/fill-paragraph syntax highlighting problem Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 29 Jun 2023 05:23:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 64329 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Yuan Fu Cc: brownts@troybrown.dev, 64329@debbugs.gnu.org Received: via spool by 64329-submit@debbugs.gnu.org id=B64329.168801615114299 (code B ref 64329); Thu, 29 Jun 2023 05:23:02 +0000 Received: (at 64329) by debbugs.gnu.org; 29 Jun 2023 05:22:31 +0000 Received: from localhost ([127.0.0.1]:52068 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qEk6w-0003iZ-Rl for submit@debbugs.gnu.org; Thu, 29 Jun 2023 01:22:31 -0400 Received: from eggs.gnu.org ([209.51.188.92]:59702) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qEk6t-0003iM-Ui for 64329@debbugs.gnu.org; Thu, 29 Jun 2023 01:22:28 -0400 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 1qEk6o-0001hD-Fc; Thu, 29 Jun 2023 01:22:22 -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=pRaOq7ZpCQ6x9gfIBNf94Ny0G5+gFO1NclVwk06MpK4=; b=H9Gu6dzutFNA9ELxru2J H9DqGtZBOYYDlc1sTJuqHPBMsd9f5EQocEvO5H//FyRcChdbqg0f/FxPkkOhSmw065jh/FLRknuy/ EF7e8G/vmk9VkdIVR1S40yQ5TCo7hZzlaOq8RagF5L1VWs5VWmaEVcl/8vhbD1jbG5RK9UhIpOOPb Yw7IQQ8be3v/4J/f7vf6CqtjiR4Qmem35wZ1JlfFuV8M3uumLOoBr/ZkpdpzMMJvxziAIlyVdV13h fpBEuf2U7nLyMWizjfmg1OIt/eowuik8VocXTFZ1ErWcFwns7tFSs6YiVshuHfGEiKzxPoGQND7eI qWkkhGC7nqk6QQ==; 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 1qEk6n-0005iv-GE; Thu, 29 Jun 2023 01:22:22 -0400 Date: Thu, 29 Jun 2023 08:22:49 +0300 Message-Id: <83r0puu9jq.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: <14493480-9226-4AB1-A313-E4E2D61AB0BD@gmail.com> (message from Yuan Fu on Wed, 28 Jun 2023 17:17:14 -0700) References: <3031A934-37EC-497D-8A48-ECE7FD703B31@gmail.com> <14493480-9226-4AB1-A313-E4E2D61AB0BD@gmail.com> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Yuan Fu > Date: Wed, 28 Jun 2023 17:17:14 -0700 > Cc: 64329@debbugs.gnu.org, > Eli Zaretskii > > Prompted by this, I went over all the functions that calls signal_after_change again, and found two other editfns.c functions that are missing calls to treesit_record_change. Please see the attached patches that follows the previous one. Sorry for the overlook. I believe I’ve found all places that needs to call treesit_record_change now. > > > 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.) > > Since now there are three functions in editfns.c that needs to call treesit_record_change, we might as well just include treesit.h and call treesit_record_change directly. Right. From unknown Wed Jun 25 00:27:16 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Troy Brown Subject: bug#64329: closed (Re: bug#64329: 29.0.92; treesit/fill-paragraph syntax highlighting problem) Message-ID: References: <9B70253C-512B-463D-B04C-CC33D486FFE0@gmail.com> X-Gnu-PR-Message: they-closed 64329 X-Gnu-PR-Package: emacs Reply-To: 64329@debbugs.gnu.org Date: Thu, 29 Jun 2023 18:18:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1688062682-9352-1" This is a multi-part message in MIME format... ------------=_1688062682-9352-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #64329: 29.0.92; treesit/fill-paragraph syntax highlighting problem which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 64329@debbugs.gnu.org. --=20 64329: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D64329 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1688062682-9352-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 64329-done) by debbugs.gnu.org; 29 Jun 2023 18:17:46 +0000 Received: from localhost ([127.0.0.1]:53994 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qEwDC-0002QO-Hq for submit@debbugs.gnu.org; Thu, 29 Jun 2023 14:17:46 -0400 Received: from mail-pl1-f180.google.com ([209.85.214.180]:59574) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qEwD9-0002Q7-St for 64329-done@debbugs.gnu.org; Thu, 29 Jun 2023 14:17:44 -0400 Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-1b8171718a1so8059615ad.2 for <64329-done@debbugs.gnu.org>; Thu, 29 Jun 2023 11:17:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688062658; x=1690654658; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Tma/Oq+zPAZ3R4fBHNqE8uY3a2xP+mmFWarg17yhv50=; b=ftC9Rntw+JLMW0rfM/1wYNyilLd1vBhUi/ceaMH//nVTEIyIUkFI271ZB4STBiuo6W sZfksEDg+gabqtLXSevlE6mZx6sVgwQyZ/7f54yB40JoxqiF88Wi+kxv5WF3zWrz1yiZ 2l2tYMmQk84gGvh0Y1Ks2r3Y3pbxwXC4yMH7mReiGyWQeuRbntU62d/FZGKNBn7qYXV0 dOaEUNH+zUHdJeETAt6xL4tZs4Gz6s8t7z6kHMPN4pG1AxzLU9MiQTi9vqumqwJFp/xd vRsXzGRpO0cWQYfha4OmIwvIJtUof0AQgD/oh/eGGkk/IwoiMDAKOmaupcM9kLmpYhEe 46OA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688062658; x=1690654658; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Tma/Oq+zPAZ3R4fBHNqE8uY3a2xP+mmFWarg17yhv50=; b=TfIH4hB9MBtattVvSP1lP7gm5CTbuB2Ji7GgV0Y0tMgvv4w+SI8hAQJ5GWJg4VntsZ Be2qsoun+A0lSPmhdaCw0unDUxhNU4NxXf5a/ulePkBwD7yHsOqa7LD4HJ9orJWPK3Pv VJ6+HT7ySPvQwU1s1C2X1TM8XaUPDy0OUVJisoUKJOJBryvdxn2vQZh5zRCk85zIiweA euxqcL1ZRyNpJtWXnH/dh1QuGYVDT2hKqKZaBHAgOQsRnczhJ+Rrtm/3KI9N9UalvfJB gamrU95Bc+QJG1w9W/TAwwr9tdRJWwUJLS6E11KDju2wLf/VnfMMerKHhspfhBXh2vLh wsCw== X-Gm-Message-State: AC+VfDz0nWAJOmwaoDgyP2tMaAdL4r+2Ts52p03RDMpakIxvKNeWwT4B t13v0RQ6ugS8UMNLh6+zc9A= X-Google-Smtp-Source: ACHHUZ7HsdEM1mjfGNKD5CdvXBEFBQ88ae6nQY5YolsrHodM0KFE/OTzvRCYRgHZhj2Vrq2/5wxfeA== X-Received: by 2002:a17:902:bb89:b0:1ac:7345:f254 with SMTP id m9-20020a170902bb8900b001ac7345f254mr16332325pls.33.1688062657846; Thu, 29 Jun 2023 11:17:37 -0700 (PDT) Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id b21-20020a170902d31500b001b85bd8fb3csm1102328plc.77.2023.06.29.11.17.36 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Jun 2023 11:17:37 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.600.7\)) Subject: Re: bug#64329: 29.0.92; treesit/fill-paragraph syntax highlighting problem From: Yuan Fu In-Reply-To: <83r0puu9jq.fsf@gnu.org> Date: Thu, 29 Jun 2023 11:17:26 -0700 Content-Transfer-Encoding: quoted-printable Message-Id: <9B70253C-512B-463D-B04C-CC33D486FFE0@gmail.com> References: <3031A934-37EC-497D-8A48-ECE7FD703B31@gmail.com> <14493480-9226-4AB1-A313-E4E2D61AB0BD@gmail.com> <83r0puu9jq.fsf@gnu.org> To: Eli Zaretskii X-Mailer: Apple Mail (2.3731.600.7) X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 64329-done Cc: Troy Brown , 64329-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) > On Jun 28, 2023, at 10:22 PM, Eli Zaretskii wrote: >=20 >> From: Yuan Fu >> Date: Wed, 28 Jun 2023 17:17:14 -0700 >> Cc: 64329@debbugs.gnu.org, >> Eli Zaretskii >>=20 >> Prompted by this, I went over all the functions that calls = signal_after_change again, and found two other editfns.c functions that = are missing calls to treesit_record_change. Please see the attached = patches that follows the previous one. Sorry for the overlook. I believe = I=E2=80=99ve found all places that needs to call treesit_record_change = now. >>=20 >>> Please see the attached patch. Eli, is it more preferable to add a = subroutine in insdel.c that does what "for (i =3D 0; i < len; i++) *p++ = =3D tostr[I];=E2=80=9D does, plus calling treesit_record_change, and = make subst-char-in-region call that subroutine? (This way editfns.c = don=E2=80=99t need to include treesit.h and call treesit_record_change = itself.) >>=20 >> Since now there are three functions in editfns.c that needs to call = treesit_record_change, we might as well just include treesit.h and call = treesit_record_change directly. >=20 > Right. Ok, I've pushed the changes. Yuan= ------------=_1688062682-9352-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 28 Jun 2023 16:46:26 +0000 Received: from localhost ([127.0.0.1]:51521 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qEYJF-0006mt-79 for submit@debbugs.gnu.org; Wed, 28 Jun 2023 12:46:26 -0400 Received: from lists.gnu.org ([209.51.188.17]:55548) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qEYJA-0006mi-Cy for submit@debbugs.gnu.org; Wed, 28 Jun 2023 12:46:24 -0400 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 1qEYJA-0007wx-6P for bug-gnu-emacs@gnu.org; Wed, 28 Jun 2023 12:46:20 -0400 Received: from mail-lf1-f46.google.com ([209.85.167.46]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qEYJ8-000628-CL for bug-gnu-emacs@gnu.org; Wed, 28 Jun 2023 12:46:19 -0400 Received: by mail-lf1-f46.google.com with SMTP id 2adb3069b0e04-4fb8574a3a1so3457774e87.1 for ; Wed, 28 Jun 2023 09:46:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687970776; x=1690562776; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=NEC1NcKmJ//v629v4OB3PteJRrCqi2sTpVeLZerkWNQ=; b=Ejw899Ia4lN0VpMqd8Io0/qkgkOjVo/QUQflTvJUjaGNXDaOJDvbNwZOze8mN2Nx9G 1kas1ZPBRA+MdcNqAZoHMRTnS62w4Ms3lBAOV8bv206s+2JbTbnjVMh4ME2oPBDoBaQ7 ES8s4iJPLQvhEQncngdJ5uvBRGNA4uxm+Pf6R9Xh9l9ipvNoYNAl/9b/3EHUWbbyFnvj wmewkKM2RY7DhVdlHvCFvD+8jmktrC/Va9W+xWtNNtBLTZGu5XH3hW7F/kD3D1IBeDE9 PnelNERMB+tlZj9qfRwKyKsNd9i/rsDyLtzAlqfCJdrUA6YqljyNBbHTdt1aTLuKZYDJ teIw== X-Gm-Message-State: AC+VfDzILzZezYxh7jKUsG6UoWijIqxY039CmXdxTOQw9PU/LdDt9e9b 4jjM/ag5YzgkBBG35wfRJ6YRkDTMjbbJk2z6yb4= X-Google-Smtp-Source: ACHHUZ6ks4fhYPU59pQi6WeH7/tE1oSSPQpebv0RxrnUYnQpwaZhDhrbkzcACIRWCtLLRjegQJtHpg== X-Received: by 2002:a05:6512:ea7:b0:4f6:1433:fca0 with SMTP id bi39-20020a0565120ea700b004f61433fca0mr22954064lfb.0.1687970776024; Wed, 28 Jun 2023 09:46:16 -0700 (PDT) Received: from mail-lf1-f50.google.com (mail-lf1-f50.google.com. [209.85.167.50]) by smtp.gmail.com with ESMTPSA id z14-20020a19f70e000000b004fa35167729sm1855324lfe.159.2023.06.28.09.46.15 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 28 Jun 2023 09:46:15 -0700 (PDT) Received: by mail-lf1-f50.google.com with SMTP id 2adb3069b0e04-4fb8ede27eeso1867870e87.0 for ; Wed, 28 Jun 2023 09:46:15 -0700 (PDT) X-Received: by 2002:a05:6512:3985:b0:4fb:96ff:35d7 with SMTP id j5-20020a056512398500b004fb96ff35d7mr783531lfu.22.1687970775478; Wed, 28 Jun 2023 09:46:15 -0700 (PDT) MIME-Version: 1.0 From: Troy Brown Date: Wed, 28 Jun 2023 12:46:04 -0400 X-Gmail-Original-Message-ID: Message-ID: Subject: 29.0.92; treesit/fill-paragraph syntax highlighting problem To: bug-gnu-emacs@gnu.org Content-Type: text/plain; charset="UTF-8" Received-SPF: pass client-ip=209.85.167.46; envelope-from=troy.s.brown@gmail.com; helo=mail-lf1-f46.google.com X-Spam_score_int: -13 X-Spam_score: -1.4 X-Spam_bar: - X-Spam_report: (-1.4 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.1 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.1 (--) I've noticed this problem on multiple tree-sitter major modes including c-ts-mode, c++-ts-mode, java-ts-mode, bash-ts-mode. I haven't tried others, but I suspect those might also suffer from this problem. The issue occurs when attempting to fill the paragraph of a comment block. The following comment block can be used as an example to reproduce the problem and happens with "emacs -Q" (assuming corresponding tree-sitter libraries are available). --8<---------------cut here---------------start------------->8--- // The quick brown fox jumps over the // lazy dog. // The quick brown fox jumps over the lazy dog. --8<---------------cut here---------------end--------------->8--- Switch to one of the tree-sitter modes (e.g., M-x java-ts-mode). Move point to the first line of the comment block above and then execute the fill-paragraph command (i.e., M-q). The text which is wrapped onto the first line of the comment block will be highlighted incorrectly. The results appear as if the comment delimiter was removed, fontification occurred, then the text was moved to the first line of the comment block and never refontified with the comment face. ------------=_1688062682-9352-1--