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#59630: 29.0.50; treesitter-buffer-root-node doesn't change when changing buffer restriction Date: Mon, 28 Nov 2022 14:09:22 +0200 Message-ID: <831qpnp9fx.fsf@gnu.org> References: <87zgcc1s1n.fsf@miha-pc> <5C98EB8D-3A4A-4F07-BF0F-F3B9F1ED004D@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="30725"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 59630@debbugs.gnu.org, miha@kamnitnik.top To: Yuan Fu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Nov 28 13:09:24 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 1ozcwt-0007iU-JU for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 28 Nov 2022 13:09:23 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ozcwb-0006CJ-QX; Mon, 28 Nov 2022 07:09:05 -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 1ozcwY-0006C0-H0 for bug-gnu-emacs@gnu.org; Mon, 28 Nov 2022 07:09: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 1ozcwY-0006vI-8l for bug-gnu-emacs@gnu.org; Mon, 28 Nov 2022 07:09:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ozcwX-0001HP-TV for bug-gnu-emacs@gnu.org; Mon, 28 Nov 2022 07:09: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: Mon, 28 Nov 2022 12:09:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59630 X-GNU-PR-Package: emacs Original-Received: via spool by 59630-submit@debbugs.gnu.org id=B59630.16696373404913 (code B ref 59630); Mon, 28 Nov 2022 12:09:01 +0000 Original-Received: (at 59630) by debbugs.gnu.org; 28 Nov 2022 12:09:00 +0000 Original-Received: from localhost ([127.0.0.1]:48182 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ozcwW-0001HB-Fx for submit@debbugs.gnu.org; Mon, 28 Nov 2022 07:09:00 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:55038) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ozcwV-0001H5-5J for 59630@debbugs.gnu.org; Mon, 28 Nov 2022 07:08:59 -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 1ozcwO-0006uj-Md; Mon, 28 Nov 2022 07:08:52 -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=jYSXNLmtOQEqcjYdZpsKqW+dtvciJcS5HOBewFWqvv4=; b=gZ7HlW+YVQ8e/GpmDSnC Y+Shpm5kavSFR9Eh6IjESYn7WREasIPYMoxajM3Ks5iTsgWDtF/uq5DDZWAcAO5q+UX71tlE/bDCm 3RnRPlgfngd+hLrUWORmWC+OLUvpva+J5tfvSqmb+PY3HJrICGXRBP0rHaSSFmj0IVoQdII+PPhtD nTB/AcGvYco+NCC/RXiani26Ilyqs84Cx7TKpG0uRBX8qwqFIAtqTA4pELjoOEyYUxD1h9ORa4UxU 2LDKgWn8Uo4tgeKpTTZi5khZVvEgfNiCPo+mwvH1tp4OxRJUwHAj8UNhoY1rFbLtcqdB0pP2WbeAp 09qKUsA31Kw6qA==; 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 1ozcwN-0003pS-V6; Mon, 28 Nov 2022 07:08:52 -0500 In-Reply-To: <5C98EB8D-3A4A-4F07-BF0F-F3B9F1ED004D@gmail.com> (message from Yuan Fu on Sun, 27 Nov 2022 14:40:41 -0800) 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:249283 Archived-At: > From: Yuan Fu > Date: Sun, 27 Nov 2022 14:40:41 -0800 > Cc: 59630@debbugs.gnu.org, > Eli Zaretskii > > > ELISP> (widen) > > ELISP> (treesit-buffer-root-node 'bash) > > # > (program) > > in 1-4> ;; <---- This is not expected, the root node should span 1-9 > > > > ELISP> (buffer-string) > > "echo '123'" > > Thanks. We didn’t edit the buffer after widening, so tree-sitter didn’t reparse and used the old tree, which sees the narrowed buffer. Eli, what would be a good and reliable way to know that narrowing has changed? I see current_buffer->clip_changed set to 1 in narrow-to-region and widen, but when are they set to 0? Not sure what exactly are you after. If you want to catch the moment when we change the buffer restriction, you will have to add something to Fnarrow_to_region and Fwiden. However, why does tree-sitter need to know about changes in the narrowing, unless it is asked to update something or produce a tree? I thought we decided to update this stuff lazily, only when actually needed? Being sensitive to these changes would require you to have some logic, because a buffer can be narrowed and widened several times in a sequence without any consequences for tree-sitter, and asking the parser to update itself will just burn CPU cycles. So if this is really needed, let's discuss for which purposes and under what conditions. I actually don't think why we should be worried by the above scenario; can you explain? To answer your question: the clip_changed flag is reset in reconsider_clip_changes, which is called at the beginning of redisplay, and when a window's redisplay is successfully completed (see mark_window_display_accurate_1). However, this flag is not meaningful outside of redisplay, in particular when redisplay cycle is NOT running. So I'm not sure it is what you want.