From debbugs-submit-bounces@debbugs.gnu.org Tue Jun 27 22:24:13 2023 Received: (at submit) by debbugs.gnu.org; 28 Jun 2023 02:24:13 +0000 Received: from localhost ([127.0.0.1]:49768 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qEKqq-0003Sl-LO for submit@debbugs.gnu.org; Tue, 27 Jun 2023 22:24:13 -0400 Received: from lists.gnu.org ([209.51.188.17]:38080) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qEKqo-0003Sd-5T for submit@debbugs.gnu.org; Tue, 27 Jun 2023 22:24:10 -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 1qEKqn-0001Jk-A5 for bug-gnu-emacs@gnu.org; Tue, 27 Jun 2023 22:24:09 -0400 Received: from mail-ej1-f45.google.com ([209.85.218.45]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qEKql-0005DO-Kd for bug-gnu-emacs@gnu.org; Tue, 27 Jun 2023 22:24:09 -0400 Received: by mail-ej1-f45.google.com with SMTP id a640c23a62f3a-98dfb3f9af6so610828666b.2 for ; Tue, 27 Jun 2023 19:24:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687919045; x=1690511045; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=7hc/BnQNm1XIsFI+xUrkhNpybGeUIXOqX3Hv47yDOAc=; b=gSjhH4RqeoPyIjboMcEQLa63rX7nUHRMknugG4OoHnE2wQbUhid23tWzturpP5jluE u6Nz/Aog/hsYzf7+LTvacZCE56E/P6DG/CelaovLPC57peIS1Thw4quF1r8hyD97dOgy jqhV2yaMtYmFNYamKNBurP+c3qF3lm/vbf8S42XHzFyCj5y/yy5i9DuaEUPzbf33+Hxh 1db7GJRd4YJZ+Q8GXSX/f623OZJiTVSLMLEwgIyhWbV7SLzA/HGiq3VzB9czdmhrYPjg //iwEXVYUbPnO6MqjM2/23eI5meJA9ek5ZJMv2vARCTWBkjZfOC004Io+U1AwYWtA+M6 xpag== X-Gm-Message-State: AC+VfDwM2AVYTAS3IWCAGqHgDz/ed3V/6twHJQPnvCrE86hU6p4Qy0AU CgrWEhnrNAvSKpdFSgISOL5GQHSb2kh6Bw== X-Google-Smtp-Source: ACHHUZ7c9g22z9NQUXF99Oedjv/V1DK6JJ3MoJ3qYgNtjOY3Lmh50D22KjUh6fAGwJ/+yicpViAgMQ== X-Received: by 2002:a17:906:6a0f:b0:992:8092:c109 with SMTP id qw15-20020a1709066a0f00b009928092c109mr44962ejc.51.1687919044543; Tue, 27 Jun 2023 19:24:04 -0700 (PDT) Received: from mail-ed1-f49.google.com (mail-ed1-f49.google.com. [209.85.208.49]) by smtp.gmail.com with ESMTPSA id lr3-20020a170906fb8300b00973f1cd586fsm5175537ejb.1.2023.06.27.19.24.03 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 27 Jun 2023 19:24:04 -0700 (PDT) Received: by mail-ed1-f49.google.com with SMTP id 4fb4d7f45d1cf-51d89664272so4893972a12.1 for ; Tue, 27 Jun 2023 19:24:03 -0700 (PDT) X-Received: by 2002:a17:907:708:b0:97b:956f:e6b5 with SMTP id xb8-20020a170907070800b0097b956fe6b5mr30428773ejb.23.1687919043655; Tue, 27 Jun 2023 19:24:03 -0700 (PDT) MIME-Version: 1.0 From: Troy Brown Date: Tue, 27 Jun 2023 22:23:52 -0400 X-Gmail-Original-Message-ID: Message-ID: Subject: 29.0.92; Tree-Sitter/which-function Narrow/Widen causes modified buffer To: bug-gnu-emacs@gnu.org Content-Type: text/plain; charset="UTF-8" Received-SPF: pass client-ip=209.85.218.45; envelope-from=troy.s.brown@gmail.com; helo=mail-ej1-f45.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.25, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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 (--) This problem seems to manifest with multiple tree-sitter modes. It appears there is an interaction with which-function-mode and tree-sitter which causes the buffer to be considered modified either after a narrow or widen of the buffer. To reproduce this, use a "hello_world.c" as follows: --8<---------------cut here---------------start------------->8--- #include int main (void) { printf("Hello, world!\n"); return 0; } --8<---------------cut here---------------end--------------->8--- Running "emacs -Q" with the corresponding tree-sitter grammar library installed. Move into the main function and narrow-to-defun. In some modes, I've seen this cause the buffer to show as modified, however with this example, it seems to occur after widening. The following sequence of commands can be used to reproduce the issue: C-x C-f ~/hello_world.c M-x c-ts-mode M-x which-function-mode C-x n d C-x n w At this point, the modeline shows that the buffer is modified, and running "M-: (buffer-modified-p)" indicates "t". As previously mentioned, this appears to only happen with tree-sitter modes when which-function-mode is enabled in the buffer. I then repeated the same but also triggered a backtrace on the first change as follows: M-: (add-to-list 'first-change-hook #'backtrace) With that in place, the following is the generated traceback: backtrace() treesit--font-lock-notifier(((1 . 21)) #) treesit-buffer-root-node(c) treesit-node-at(68) treesit--things-around(68 "\\(?:class_specifier\\|enum_specifier\\|function_defi..." c-ts-mode--defun-valid-p) treesit-thing-at-point(("\\(?:class_specifier\\|enum_specifier\\|function_defi..." . c-ts-mode--defun-valid-p) top-level) treesit-defun-at-point() treesit-add-log-current-defun() c-ts-mode--emacs-current-defun-name() add-log-current-defun() which-function() which-func-update-1(#) which-func-update() apply(which-func-update nil) timer-event-handler([t 0 0 500000 t which-func-update nil idle 0 nil]) From debbugs-submit-bounces@debbugs.gnu.org Wed Jun 28 00:04:43 2023 Received: (at 64321) by debbugs.gnu.org; 28 Jun 2023 04:04:43 +0000 Received: from localhost ([127.0.0.1]:49854 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qEMQ6-0006Co-QZ for submit@debbugs.gnu.org; Wed, 28 Jun 2023 00:04:43 -0400 Received: from mail-pj1-f48.google.com ([209.85.216.48]:56762) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qEMQ4-0006Cb-Ps for 64321@debbugs.gnu.org; Wed, 28 Jun 2023 00:04:41 -0400 Received: by mail-pj1-f48.google.com with SMTP id 98e67ed59e1d1-262ef07be72so1798955a91.1 for <64321@debbugs.gnu.org>; Tue, 27 Jun 2023 21:04:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687925075; x=1690517075; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:from:to:cc:subject:date:message-id:reply-to; bh=RV3rQQikb/+EdG1rC1wHfF4Sj9ERQQFMJnGcGpVOC0o=; b=eI7J7DroePxjXcVR79SunhJ9uEr6yll/a8q2/Q5wzhJsNHRBEqOL42n4AW54HXUlS6 2IS5qtliR6DKN0rCKptDOaG7tgiOrOOtS7UjnQY+3OcuBqtdGnmYY728sOVBZQ/X/X9E rYvO9I6vyerRpXCxN8ZFrYwWcrMWsFs/QdNowkgBeE1XCnIGfGkPnnOsBgCDCcciBOUr XN+Z5W3y2CfxvUfNko91D7LkGKsFBtRujLTQ+FfORwt/27AyrTyLkXzjh/lRm2VJkaWT 8J54t5TMtK+Gv5eWmRSCCE44wPDLJqD2KOrRBPbS8/TbdKWFLJ8R3TcH2eV/vQVR42Ne t+Eg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687925075; x=1690517075; 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=RV3rQQikb/+EdG1rC1wHfF4Sj9ERQQFMJnGcGpVOC0o=; b=SdwX8AdDDF5p0WBNuuYYzeB0ctQU58XdPa0dMM2UP5weDqksrmsJNM1NKOouSeLegH kQPdKSvBlxHXhSZwMM4doMFJirad2qCBgFj93lGhePoMIZuM6G7Krw9kdX6xv0VVBcq0 EAgVXxU15oF08UNIKRNZjNoJxsElvOhp9rifeWqZGevq9z1S47VDoLtOHnh94yMfluRR 1X25SZNGxDXweAdptLOho/j8+bNrCxwFHeJ2JKbHXTGfDmgPT/EBO3ik/RONmI80ZyeN 1LraBM1gDAHNN/sCnv3Awz6No7rZ3mHUGYhd/jo99dq193SYVew8c4Be5Dq0+Vn3Txeb vgug== X-Gm-Message-State: AC+VfDxWCdkikRJSadFuS9bCM31xoa893abBJdQPKpzeVAE3DoyiRkkG oHW6kuZAAQAH/tAMRXQZ27e7gJDPa8U= X-Google-Smtp-Source: ACHHUZ4VZqbP8zUTBegQZ3qfpSqDp18OVs5iCaQdFp4NbXCNN8xEXUAvMDjQIIIgBpcsXSUSTLnTOA== X-Received: by 2002:a17:90a:f689:b0:262:df1d:4535 with SMTP id cl9-20020a17090af68900b00262df1d4535mr6249780pjb.31.1687925074473; Tue, 27 Jun 2023 21:04:34 -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 q34-20020a17090a1b2500b00262e485156esm5566697pjq.57.2023.06.27.21.04.33 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Jun 2023 21:04:34 -0700 (PDT) From: Yuan Fu Message-Id: <8D52F265-1596-4D95-BFCD-75C897412AC2@gmail.com> Content-Type: multipart/mixed; boundary="Apple-Mail=_8481864E-C3BF-4916-9327-ED4D15B40C60" Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.600.7\)) Subject: Re: bug#64321: 29.0.92; Tree-Sitter/which-function Narrow/Widen causes modified buffer Date: Tue, 27 Jun 2023 21:04:22 -0700 In-Reply-To: To: Troy Brown References: X-Mailer: Apple Mail (2.3731.600.7) X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 64321 Cc: Eli Zaretskii , 64321@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 (-) --Apple-Mail=_8481864E-C3BF-4916-9327-ED4D15B40C60 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Jun 27, 2023, at 7:23 PM, Troy Brown wrote: >=20 > This problem seems to manifest with multiple tree-sitter modes. It > appears there is an interaction with which-function-mode and = tree-sitter > which causes the buffer to be considered modified either after a = narrow > or widen of the buffer. >=20 > To reproduce this, use a "hello_world.c" as follows: >=20 > --8<---------------cut here---------------start------------->8--- > #include >=20 > int main (void) > { > printf("Hello, world!\n"); > return 0; > } > --8<---------------cut here---------------end--------------->8--- >=20 > Running "emacs -Q" with the corresponding tree-sitter grammar library > installed. Move into the main function and narrow-to-defun. In some > modes, I've seen this cause the buffer to show as modified, however = with > this example, it seems to occur after widening. >=20 > The following sequence of commands can be used to reproduce the issue: >=20 > C-x C-f ~/hello_world.c > M-x c-ts-mode > M-x which-function-mode > C-x n d > C-x n w >=20 > At this point, the modeline shows that the buffer is modified, and > running "M-: (buffer-modified-p)" indicates "t". As previously > mentioned, this appears to only happen with tree-sitter modes when > which-function-mode is enabled in the buffer. >=20 > I then repeated the same but also triggered a backtrace on the first > change as follows: >=20 > M-: (add-to-list 'first-change-hook #'backtrace) >=20 > With that in place, the following is the generated traceback: >=20 > backtrace() > treesit--font-lock-notifier(((1 . 21)) #) > treesit-buffer-root-node(c) > treesit-node-at(68) > treesit--things-around(68 > "\\(?:class_specifier\\|enum_specifier\\|function_defi..." > c-ts-mode--defun-valid-p) > = treesit-thing-at-point(("\\(?:class_specifier\\|enum_specifier\\|function_= defi..." > . c-ts-mode--defun-valid-p) top-level) > treesit-defun-at-point() > treesit-add-log-current-defun() > c-ts-mode--emacs-current-defun-name() > add-log-current-defun() > which-function() > which-func-update-1(#) > which-func-update() > apply(which-func-update nil) > timer-event-handler([t 0 0 500000 t which-func-update nil idle 0 = nil]) Thanks for the backtrace, it=E2=80=99s very helpful. Narrowing and widening are transparent to tree-sitter, so when the = buffer widens, from tree-sitter=E2=80=99s POV, text are added to the = buffer. Which-func calling the tree-sitter current-defund function = ultimately leads to tree-sitter calling treesit=E2=80=94font-lock-notifier= which puts text properties on the =E2=80=9Cadded=E2=80=9D portion of = the buffer, which changed the modified status. treesit=E2=80=94font-lock-notifier should put text properties without = changing modified status, like what jit-lock does. This patch should fix = it. Yuan --Apple-Mail=_8481864E-C3BF-4916-9327-ED4D15B40C60 Content-Disposition: attachment; filename=silent.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="silent.patch" Content-Transfer-Encoding: quoted-printable =46rom=202c90ade09a4d52a583158cb9cacf665ac11e8387=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20Yuan=20Fu=20=0ADate:=20Tue,=20= 27=20Jun=202023=2020:58:34=20-0700=0ASubject:=20[PATCH]=20Tree-sitter=20= use=20with-silent-modifications=20like=20jit-lock=0A=20(bug#64321)=0A=0A= *=20lisp/treesit.el=20(treesit--font-lock-notifier):=20Use=0A= with-silent-modifications=20when=20marking=20modified=20text=20to=20be=20= fontified=0Aby=20jit-lock.=20=20This=20is=20what=20jit-lock=20itself=20= does.=0A---=0A=20lisp/treesit.el=20|=203=20++-=0A=201=20file=20changed,=20= 2=20insertions(+),=201=20deletion(-)=0A=0Adiff=20--git=20= a/lisp/treesit.el=20b/lisp/treesit.el=0Aindex=200e1d7931d49..04d460fdea4=20= 100644=0A---=20a/lisp/treesit.el=0A+++=20b/lisp/treesit.el=0A@@=20= -1072,7=20+1072,8=20@@=20treesit--font-lock-notifier=0A=20=20=20=20=20=20= =20(when=20treesit--font-lock-verbose=0A=20=20=20=20=20=20=20=20=20= (message=20"Notifier=20received=20range:=20%s-%s"=0A=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20(car=20range)=20(cdr=20range)))=0A-=20=20= =20=20=20=20(put-text-property=20(car=20range)=20(cdr=20range)=20= 'fontified=20nil))))=0A+=20=20=20=20=20=20(with-silent-modifications=0A+=20= =20=20=20=20=20=20=20(put-text-property=20(car=20range)=20(cdr=20range)=20= 'fontified=20nil)))))=0A=20=0A=20;;;=20Indent=0A=20=0A--=20=0A2.33.1=0A=0A= --Apple-Mail=_8481864E-C3BF-4916-9327-ED4D15B40C60 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii --Apple-Mail=_8481864E-C3BF-4916-9327-ED4D15B40C60-- From debbugs-submit-bounces@debbugs.gnu.org Wed Jun 28 08:01:05 2023 Received: (at 64321) by debbugs.gnu.org; 28 Jun 2023 12:01:05 +0000 Received: from localhost ([127.0.0.1]:50204 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qETr7-0004nb-Bs for submit@debbugs.gnu.org; Wed, 28 Jun 2023 08:01:05 -0400 Received: from eggs.gnu.org ([209.51.188.92]:54416) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qETr2-0004mu-Es for 64321@debbugs.gnu.org; Wed, 28 Jun 2023 08:01:04 -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 1qETqx-0006Cw-02; Wed, 28 Jun 2023 08:00:55 -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=3sD/FheWJ1d9RY3VDGek7uBdCVhFOZUyj2+d4jjFMLM=; b=Iz2UlvK1XStAvU3Yeud6 WI7TGsIs7gKOlVQFC+Q7Wum1olS5GsdQLqH+eMUPkFlVAEZVsxvw1ehZqz4RhFq8BRXmCFCG4XwJV 7/DmqzjlcuSK3uA8QKbHB3YNRh3uNv53rPiIZ6/mOaVzAbVvatAvg6zv4Mi7cdYqFOWWLBDBxLv1E E5AthNhtuPTjMNDpEfKK+tU510q8F8aF+lkaZnaKlfFpfZVisvCtkluKMMNS53BoIIQxNbZpRtx4x Pad0ciwRlSu1KZMEv0mVvkAhLK2EFRbPync5Fxh3mR5zylaYO4guuh4zIeweodwmFTc+QAV4YOrwI Qwv6REFebICN7w==; 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 1qETqm-0002T4-MX; Wed, 28 Jun 2023 08:00:54 -0400 Date: Wed, 28 Jun 2023 15:01:07 +0300 Message-Id: <83jzvnvlrw.fsf@gnu.org> From: Eli Zaretskii To: Yuan Fu In-Reply-To: <8D52F265-1596-4D95-BFCD-75C897412AC2@gmail.com> (message from Yuan Fu on Tue, 27 Jun 2023 21:04:22 -0700) Subject: Re: bug#64321: 29.0.92; Tree-Sitter/which-function Narrow/Widen causes modified buffer References: <8D52F265-1596-4D95-BFCD-75C897412AC2@gmail.com> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 64321 Cc: brownts@troybrown.dev, 64321@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: -3.3 (---) > From: Yuan Fu > Date: Tue, 27 Jun 2023 21:04:22 -0700 > Cc: 64321@debbugs.gnu.org, > Eli Zaretskii > > Thanks for the backtrace, it’s very helpful. > > Narrowing and widening are transparent to tree-sitter, so when the buffer widens, from tree-sitter’s POV, text are added to the buffer. Which-func calling the tree-sitter current-defund function ultimately leads to tree-sitter calling treesit—font-lock-notifier which puts text properties on the “added” portion of the buffer, which changed the modified status. > > treesit—font-lock-notifier should put text properties without changing modified status, like what jit-lock does. This patch should fix it. Thanks. If this solves the problem, please install in the emacs-29 release branch. From debbugs-submit-bounces@debbugs.gnu.org Wed Jun 28 12:25:24 2023 Received: (at 64321) by debbugs.gnu.org; 28 Jun 2023 16:25:25 +0000 Received: from localhost ([127.0.0.1]:51477 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qEXyu-0003jz-MX for submit@debbugs.gnu.org; Wed, 28 Jun 2023 12:25:24 -0400 Received: from mail-lj1-f176.google.com ([209.85.208.176]:46179) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qEXyr-0003jg-E8 for 64321@debbugs.gnu.org; Wed, 28 Jun 2023 12:25:24 -0400 Received: by mail-lj1-f176.google.com with SMTP id 38308e7fff4ca-2b69dcf45faso32731fa.0 for <64321@debbugs.gnu.org>; Wed, 28 Jun 2023 09:25:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687969515; x=1690561515; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=W34fueoEPaC27Hoc3SmJ4uR4TA9OwUBmPSjnzULzprI=; b=G6tU7pljOjCGPRc2/oZ3edkjx97MsOoW4lZtaL96un62jg0MvLul3wJUq1sJNtMaNK D6+UKRO0hRb4Bb07IiTU8nqhE8OOIBdilF0RG566+ZNxSDoIw5+nipdKLmvogiiDxw6Y 5rYpnVMFLGOT/2wTifD1OxXqGbmNmKNgk4oSlZ3oTq+a0pFL5h+fZlT5CXDT06Q5Ihp+ +Mh+KVp3I0id65rUaH0r9trD7GL+x3psguCA0v+8r/sjw8vaxzgNKl7GouKAnz1OjwYs r3Ax2RhNh1BH+9NuI7S0pbRk/To1C5g9qevrcTIdTUPwdJiannfh8Z4bjpIuG5tUo1rI JNcQ== X-Gm-Message-State: AC+VfDw9ckBCZmo+vFqitYNdcNTizXAahvtpBLHFCRVVOAQnqaMWtUC/ +rvycDEw+BX/DQAltjUYdwirUDC4AIyyy4Ma X-Google-Smtp-Source: ACHHUZ70nuqBln1S65gzqQIcKiFn9GKq6i16RTPkLCtYolVE6SxMAnU7XsvEPMLsGFeeIwkpQLKLsQ== X-Received: by 2002:a2e:9958:0:b0:2b6:99a3:c254 with SMTP id r24-20020a2e9958000000b002b699a3c254mr6856999ljj.26.1687969514540; Wed, 28 Jun 2023 09:25:14 -0700 (PDT) Received: from mail-lj1-f172.google.com (mail-lj1-f172.google.com. [209.85.208.172]) by smtp.gmail.com with ESMTPSA id l17-20020a2e8691000000b002b6a6574313sm1232081lji.62.2023.06.28.09.25.14 for <64321@debbugs.gnu.org> (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 28 Jun 2023 09:25:14 -0700 (PDT) Received: by mail-lj1-f172.google.com with SMTP id 38308e7fff4ca-2b69dcf45faso32261fa.0 for <64321@debbugs.gnu.org>; Wed, 28 Jun 2023 09:25:14 -0700 (PDT) X-Received: by 2002:a2e:9081:0:b0:2b6:a6c4:b848 with SMTP id l1-20020a2e9081000000b002b6a6c4b848mr6131691ljg.31.1687969514074; Wed, 28 Jun 2023 09:25:14 -0700 (PDT) MIME-Version: 1.0 References: <8D52F265-1596-4D95-BFCD-75C897412AC2@gmail.com> In-Reply-To: <8D52F265-1596-4D95-BFCD-75C897412AC2@gmail.com> From: Troy Brown Date: Wed, 28 Jun 2023 12:25:02 -0400 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: bug#64321: 29.0.92; Tree-Sitter/which-function Narrow/Widen causes modified buffer To: Yuan Fu Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.2 (/) X-Debbugs-Envelope-To: 64321 Cc: Eli Zaretskii , 64321@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: -0.8 (/) On Wed, Jun 28, 2023 at 12:04=E2=80=AFAM Yuan Fu wrote: > > Narrowing and widening are transparent to tree-sitter, so when the buffer= widens, from tree-sitter=E2=80=99s POV, text are added to the buffer. Whic= h-func calling the tree-sitter current-defund function ultimately leads to = tree-sitter calling treesit=E2=80=94font-lock-notifier which puts text prop= erties on the =E2=80=9Cadded=E2=80=9D portion of the buffer, which changed = the modified status. > > treesit=E2=80=94font-lock-notifier should put text properties without cha= nging modified status, like what jit-lock does. This patch should fix it. > Thanks for the explanation and the supplied patch. I can confirm that this patch fixes the issue. From debbugs-submit-bounces@debbugs.gnu.org Wed Jun 28 16:10:05 2023 Received: (at 64321-done) by debbugs.gnu.org; 28 Jun 2023 20:10:05 +0000 Received: from localhost ([127.0.0.1]:51746 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qEbUL-0006YA-7a for submit@debbugs.gnu.org; Wed, 28 Jun 2023 16:10:05 -0400 Received: from mail-il1-f175.google.com ([209.85.166.175]:61466) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qEbUF-0006XR-04 for 64321-done@debbugs.gnu.org; Wed, 28 Jun 2023 16:10:03 -0400 Received: by mail-il1-f175.google.com with SMTP id e9e14a558f8ab-345d3c10bdfso915745ab.2 for <64321-done@debbugs.gnu.org>; Wed, 28 Jun 2023 13:09:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687982993; x=1690574993; 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=sB3MXmDNTyVN2dFvlsvzHPfbhY7ZmLAep3v/B1/DCIM=; b=Mh/Ock2FpcEkrKJYrym8YBGVs3PWtTXAng+6DrhNRM3GZPouiNZkfcsnkuUOLwSLY6 dPXpwbJjEkRlw9LYoJKedhoZ5DyLcQ0PESWTNpCIzZUetbO6fSyYOIpq0ZJLSsMaRulo 92I0eZjbu4aBI9/GogAtCKSprsvx2G6tMCjVPSOJljlXBHqVq4D4XFe+jYPZRAkZQCAH iDqSip1yg/TB8CaDRQEcqCQYdW9tFrMLAj9UL311v2+yTr597sLjdBXtMQv6hUiplDNe LGUcTx0bf6uGWXNPwDUGHPDvWeA9E2OIxnhHTahdaCCxHmVv16PWlfAdh8Y1EyE811Vn XFWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687982993; x=1690574993; 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=sB3MXmDNTyVN2dFvlsvzHPfbhY7ZmLAep3v/B1/DCIM=; b=Iu00aDq7izwWRhVhNpS9003rXQd5yyFr6qMxvVy/LQUXwPwDFBBcYM3rDB9B82S3e4 b5kBuBHhzl/R9H9gAQ6Qy846ItJ6QXLz1/oqQVJ5QvGSbqiv2bbGWWbNynCfJyZmY3E9 hanap1Blbqqc0N2UUtSUueXrlWCjPZfyI+m/Nn5mSz5OPnW4TtxPjbR5qxQUkdNMLAsV aQ3+ZSbtMRmCv5rsHpKgoGb3SVNiz6AVukejiJIWWh9YOztJRQ5axK4/4qH9WcsBdwns Az06k8z9E360r/X1tqzR3sJT/EJRGQNjVDWbuL9j3WJtDlbYJCofNsRN8iro64yfM3ID 0KwA== X-Gm-Message-State: AC+VfDxSuJeTUV/JnNXTIy0is6y9tcyzh0wxU0E1wrD/qDpRUUZuCipy LGVZuhJ+/G+dzWnATnzw1Tg= X-Google-Smtp-Source: ACHHUZ6UplXfLCuQIZOBqRoMl4cY89ObT0C9ZiPwI2sn0hCO//ioyQV1fDjwVoad0xD2fx5PqwKQZg== X-Received: by 2002:a92:c141:0:b0:345:97a9:48bf with SMTP id b1-20020a92c141000000b0034597a948bfmr11453139ilh.26.1687982993059; Wed, 28 Jun 2023 13:09: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 r19-20020a634413000000b005579f12a238sm6708342pga.86.2023.06.28.13.09.52 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Jun 2023 13:09:52 -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#64321: 29.0.92; Tree-Sitter/which-function Narrow/Widen causes modified buffer From: Yuan Fu In-Reply-To: Date: Wed, 28 Jun 2023 13:09:41 -0700 Content-Transfer-Encoding: quoted-printable Message-Id: <3B76F5DF-F50C-4AFB-ADB6-5F1B76AFD58C@gmail.com> References: <8D52F265-1596-4D95-BFCD-75C897412AC2@gmail.com> To: Troy Brown X-Mailer: Apple Mail (2.3731.600.7) X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 64321-done Cc: Eli Zaretskii , 64321-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 9:25 AM, Troy Brown wrote: >=20 > On Wed, Jun 28, 2023 at 12:04=E2=80=AFAM Yuan Fu = wrote: >>=20 >> Narrowing and widening are transparent to tree-sitter, so when the = buffer widens, from tree-sitter=E2=80=99s POV, text are added to the = buffer. Which-func calling the tree-sitter current-defund function = ultimately leads to tree-sitter calling treesit=E2=80=94font-lock-notifier= which puts text properties on the =E2=80=9Cadded=E2=80=9D portion of = the buffer, which changed the modified status. >>=20 >> treesit=E2=80=94font-lock-notifier should put text properties without = changing modified status, like what jit-lock does. This patch should fix = it. >>=20 >=20 > Thanks for the explanation and the supplied patch. I can confirm that > this patch fixes the issue. Cool, thanks, pushed. Yuan= From unknown Wed Jun 25 00:25:02 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Thu, 27 Jul 2023 11:24:06 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator