From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.bugs Subject: bug#66732: tree-sitter fontification doesn't update multi-line syntax reliably Date: Wed, 20 Dec 2023 04:01:20 +0200 Message-ID: <5c59b83b-87e7-6f8e-2372-740efcc102f6@gutov.dev> References: <878r7s5cdf.fsf@honnef.co> <83fs1tbou1.fsf@gnu.org> <835y1zo3rw.fsf@gnu.org> <2ce274aa-6d01-4d0a-b10c-07f821343fed@gmail.com> <50920549-006c-0153-2471-02e41a3dada7@gutov.dev> <8c7cd429-bdc3-4fac-ad1c-fbad793bf1a0@gmail.com> <231ebcd1-ec30-0432-82e7-d63e11cd65f7@gutov.dev> <765D713E-9923-4F66-9044-9D69C104C9B0@gmail.com> <33fe5d61-5022-67c5-6a65-babde4fb7f91@gutov.dev> <92CACD38-9534-4A07-8DE3-CE8408272FB6@gmail.com> <59CC46F7-867E-4C74-83EC-49B41DF0FAB8@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4485"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Cc: Eli Zaretskii , 66732@debbugs.gnu.org, dominik@honnef.co To: Stefan Monnier , Yuan Fu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Dec 20 03:02:45 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 1rFlv0-0000uW-T4 for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 20 Dec 2023 03:02:44 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rFlua-0000qF-Me; Tue, 19 Dec 2023 21:02:19 -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 1rFluJ-0000fl-HL for bug-gnu-emacs@gnu.org; Tue, 19 Dec 2023 21:02:00 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rFluJ-00029L-95 for bug-gnu-emacs@gnu.org; Tue, 19 Dec 2023 21:01:59 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rFluM-0005w1-01 for bug-gnu-emacs@gnu.org; Tue, 19 Dec 2023 21:02:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 20 Dec 2023 02:02:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 66732 X-GNU-PR-Package: emacs Original-Received: via spool by 66732-submit@debbugs.gnu.org id=B66732.170303769422776 (code B ref 66732); Wed, 20 Dec 2023 02:02:01 +0000 Original-Received: (at 66732) by debbugs.gnu.org; 20 Dec 2023 02:01:34 +0000 Original-Received: from localhost ([127.0.0.1]:38017 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rFltu-0005vG-4M for submit@debbugs.gnu.org; Tue, 19 Dec 2023 21:01:34 -0500 Original-Received: from out1-smtp.messagingengine.com ([66.111.4.25]:43751) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rFlts-0005v3-4j for 66732@debbugs.gnu.org; Tue, 19 Dec 2023 21:01:33 -0500 Original-Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 68CE35C0286; Tue, 19 Dec 2023 21:01:23 -0500 (EST) Original-Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Tue, 19 Dec 2023 21:01:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gutov.dev; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1703037683; x=1703124083; bh=xCzugQDm8nF0sONqOxlPNFIwVnOLIVfq3YLdxN5XCOs=; b= QVe/C3vvtiW8WZ9zJP1mx66KC5JvWpf1VOMNBlo37zyvr2WTNnqEAwdG0TU0pE6R oFOKU+jf3PabJdQ82qSeJa6wZsWjhMSe+6cfWOLD7v6tlnfpBWpBvj7BzuI1ZBEv oiOrKA7Q6yxVri5IATKvWlUqU5KZlSVssGpHnZTfE/KAgnIHZJkSmGqLa6WnEm06 grWLZDuV5rYB0jrHqkhRs7lq1/o4G2vlGcNpyAxmyH1DPRJFkT5stVXY0Y9PCcuc 0Dmyxjp17E4SVS1+xd7lsCYImy4yIdAxviIAka69EsVeLeGF6uAgxPDIi6D97y1s KmvPDWhWcXojIDWXcnM3+Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1703037683; x= 1703124083; bh=xCzugQDm8nF0sONqOxlPNFIwVnOLIVfq3YLdxN5XCOs=; b=M arod8GP7uRF3aonxFn7o5IfhRvqGbRHkziyfE1dD9Mz3PEQyV4diqxKOEGQhrXOG dxYZGUzQW1T/94KVQB6K5mvqvhA9cU0NrAWPzDhA2r63pF2NlZZqNZWFljXEhmZ+ qTjhBGL+ifeB5MCSJEpDip6oa0riaSoVyXbVaTfKNLy846+y0jwxrm5qiHf64O/R 7DSgDPQz6ky5AWnOK4WEGNkXAe0Lr6xYSNVS/w+67ESDAL18H3R5QLbmy5eJTFMo CTBg8Jj40Pgai9soarphJXc+SZGNJ6wYzuk9n6ZzRb5uRJq15QmH2p7tLz3jd+6M W6GJ04mfhopalq9Fw4n2A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvdduuddggeduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepkfffgggfuffvvehfhfgjtgfgsehtjeertddtfeejnecuhfhrohhmpeffmhhi thhrhicuifhuthhovhcuoegumhhithhrhiesghhuthhovhdruggvvheqnecuggftrfgrth htvghrnhepiefgteevheevveffheeltdeukeeiieekueefgedugfefgefhudelgfefveel vdevnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepug hmihhtrhihsehguhhtohhvrdguvghv X-ME-Proxy: Feedback-ID: i0e71465a:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 19 Dec 2023 21:01:21 -0500 (EST) Content-Language: en-US In-Reply-To: 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:276547 Archived-At: On 16/12/2023 19:11, Stefan Monnier wrote: >> Hmm... This `put-text-property` can't be right. >> Can you trace `font-lock-fontify-region` and >> `font-lock-default-fontify-region` to check that they correctly return >> the proper (extended) bounds of the region they (re)fontified? > BTW, using the extend-region-function isn't ideal: this is meant for > things which can't be refontified separately, so if a change in the > buffer causes notification to make changes over a large portion of the > buffer we'll end up (re)fontified*right away* that whole large > portion even if only a small part (or even no part at all) is displayed. BTW, do you have an example of a "thing which can't be refontified separately"? Otherwise, I think a reorganization would be possible where when the region is extended to more than the visible area of the buffer, some parts of the buffer are marked as unfontified, but don't force their highlighting in the same cycle. Basically, what the pre-redisplay-functions patch does, but using the *-extend-region-functions protocol. Might not be trivial code-wise. I guess it also depends on how much we consider the current approach of requesting an additional display iteration, to be a problem (e.g. does that create any real difference performance-wise). The use of pre-redisplay-functions avoid that question, but asks the programmer to work on a lower level of abstraction (i.e. know about 'fontified' => nil), as well as possibly apply this change to a bigger region than necessary (again, not sure about the performance impact).