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#61369: Problem with keeping tree-sitter parse tree up-to-date Date: Fri, 10 Feb 2023 03:38:04 +0200 Message-ID: <6ae6d1c3-8da0-ba37-1cf8-c89cc6660858@yandex.ru> References: <934F7D4C-6AFF-4370-8C19-120764E4A372@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="17628"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Cc: theo@thornhill.no, 61369@debbugs.gnu.org To: Yuan Fu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Feb 10 02:39:17 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 1pQINg-0004Qt-4d for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 10 Feb 2023 02:39:16 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pQINU-000676-Ra; Thu, 09 Feb 2023 20:39:04 -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 1pQINS-00066E-Iz for bug-gnu-emacs@gnu.org; Thu, 09 Feb 2023 20:39: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 1pQINS-00073h-1M for bug-gnu-emacs@gnu.org; Thu, 09 Feb 2023 20:39:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pQINR-0006gQ-Tm for bug-gnu-emacs@gnu.org; Thu, 09 Feb 2023 20:39:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 10 Feb 2023 01:39:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 61369 X-GNU-PR-Package: emacs Original-Received: via spool by 61369-submit@debbugs.gnu.org id=B61369.167599309425602 (code B ref 61369); Fri, 10 Feb 2023 01:39:01 +0000 Original-Received: (at 61369) by debbugs.gnu.org; 10 Feb 2023 01:38:14 +0000 Original-Received: from localhost ([127.0.0.1]:33960 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pQIMg-0006es-Ed for submit@debbugs.gnu.org; Thu, 09 Feb 2023 20:38:14 -0500 Original-Received: from mail-ej1-f45.google.com ([209.85.218.45]:44965) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pQIMe-0006ec-LF for 61369@debbugs.gnu.org; Thu, 09 Feb 2023 20:38:13 -0500 Original-Received: by mail-ej1-f45.google.com with SMTP id hx15so11981181ejc.11 for <61369@debbugs.gnu.org>; Thu, 09 Feb 2023 17:38:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=Z+x4N1E9OWOJ4nHb+QKKnADJj7ovcn2rKk0097N/9qU=; b=E+jQXsgY0/px4mRJ/SDr3Yl8H7mRMe3jwsnwuKwlyvN+WNSgLTQ5VvjP3Js0G1bRxo 3zIyzG6E7HfJmOarLRk9j9zYI0n/bdG751oAx6YoO2IpLjyTIISLdCVh/Zs2imRGjFVj hJbrCBb74kcRFVg5Tn3hdiRkaMgU8AmRF36XnRPf3QPKccp0KlGnFowNxRot8rEnbEmE JmrnPoutTj5SnjQugJ3RhybU0/JEO8NJrqH5G9eshZfd4AOGSEb8tdByM/NhVrD9UMQb f2wABuKmp0GT6+Fkf35itQlECjbAFm3d6wqIfdwufK36oNdY0ryvpQ6stA5vG1Hog2Zy gODw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Z+x4N1E9OWOJ4nHb+QKKnADJj7ovcn2rKk0097N/9qU=; b=nmvhJLaqK/V9fq54SBeHQTAzl84daRJX3gWDBZ7lItbkF7ARWXjVfGaQT6rNq42hhY atZojzourJbJnho/Gg/+M1R+0m72pwaKZGTLzhvk8N2gw4t98+Xn4ovBSxKMQwSzud7a ymD16BMTmiiGMTritnPfy60npdyOE9m7/Wdwv57FLAftfZmlzJ9DJ2darfJ9Xyfwj5h2 oNPKVtwvk8e21xDYdFKlWiS0ZYb0/8wfn01wGKf8AEcWKZ0eN9jETjVKDcY+orTc3nYF 0eRfuG3480TcWqpln2SyqbcpjxgN12jvjCyD4TxygMKu5nLj2s/7cD668UvWTungvSo9 vxYA== X-Gm-Message-State: AO0yUKUlaSbJN+dt5mcF5eXyvkuRhQYaAXKxQE2b76EbURmNGarDB+j9 6oTn7gbfAqjADPueDUZVJxQ= X-Google-Smtp-Source: AK7set9mEEeYE493T6Q/BlziNFlagzYPyQUfKkrVxkb0qIz6lGWUn7KXcQwDn5nW+H963tim8hzthQ== X-Received: by 2002:a17:906:fad2:b0:886:221b:44de with SMTP id lu18-20020a170906fad200b00886221b44demr14618445ejb.0.1675993086671; Thu, 09 Feb 2023 17:38:06 -0800 (PST) Original-Received: from [192.168.0.2] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id a6-20020a17090680c600b008aef73e4494sm1645235ejx.108.2023.02.09.17.38.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 09 Feb 2023 17:38:05 -0800 (PST) Content-Language: en-US In-Reply-To: <934F7D4C-6AFF-4370-8C19-120764E4A372@gmail.com> 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:255261 Archived-At: On 10/02/2023 03:22, Yuan Fu wrote: >> I just want to confirm that I can reproduce this, and that if you skip >> the trailing newline from the use-statement, I don't get this behavior. >> So it seems like the newline is the crucial point, right? >> >> Yes, same. >> >> Thr trailing newline is necessary. >> >> The empty lines at the beginning of the buffer (being copied to) are necessary to reproduce this as well. > Hmmm, it might be related to how does tree-sitter does incremental > parsing? If the newline is necessary, then I guess it’s not because > Emacs missed characters when reporting edits to tree-sitter. The newline is somewhat necessary: the scenario doesn't work, for example, if the pasted text doesn't include the newline but the buffer had an additional (third) one at the top. But the scenario also doesn't work if some other (any) character is removed from the yanked line before pasting: it could be even one after the comment instruction (//). OTOH, if I add an extra char to the yanked line, anywhere, I can skip the newline. E.g. I can paste use std::path::{self, Path, PathBuf}; // good: std is a crate namee without a newline and still see the exact same syntax error. So it looks more like an off-by-one error somewhere. Maybe in our code, but maybe in tree-sitter somewhere.