From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: nvp Newsgroups: gmane.emacs.bugs Subject: bug#66431: [PATCH] Fix reset treesit--explorer-last-node when explorer buffer was killed Date: Sat, 21 Oct 2023 17:40:40 -0700 Message-ID: References: <83a5slsjmh.fsf@gnu.org> <76FD5982-60CC-48D2-9823-C235CCEC2EEC@gmail.com> <029D1797-AE78-4E45-BE25-0BEC8AF47321@gmail.com> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="0000000000008adeb10608435bf9" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="10066"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , 66431@debbugs.gnu.org To: Yuan Fu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Oct 22 02:41:47 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 1quMXK-0002Pw-KZ for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 22 Oct 2023 02:41:46 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1quMXB-0006Fp-9n; Sat, 21 Oct 2023 20:41:37 -0400 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 1quMX8-0006Fe-Pc for bug-gnu-emacs@gnu.org; Sat, 21 Oct 2023 20:41:34 -0400 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 1quMX8-0002UW-HO for bug-gnu-emacs@gnu.org; Sat, 21 Oct 2023 20:41:34 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1quMXa-00089h-5G for bug-gnu-emacs@gnu.org; Sat, 21 Oct 2023 20:42:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: nvp Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 22 Oct 2023 00:42:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 66431 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 66431-submit@debbugs.gnu.org id=B66431.169793528931308 (code B ref 66431); Sun, 22 Oct 2023 00:42:02 +0000 Original-Received: (at 66431) by debbugs.gnu.org; 22 Oct 2023 00:41:29 +0000 Original-Received: from localhost ([127.0.0.1]:45237 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1quMX3-00088u-6O for submit@debbugs.gnu.org; Sat, 21 Oct 2023 20:41:29 -0400 Original-Received: from mail-oa1-x31.google.com ([2001:4860:4864:20::31]:51221) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1quMX0-00088g-Gl for 66431@debbugs.gnu.org; Sat, 21 Oct 2023 20:41:27 -0400 Original-Received: by mail-oa1-x31.google.com with SMTP id 586e51a60fabf-1e9b6f39f9eso1644822fac.2 for <66431@debbugs.gnu.org>; Sat, 21 Oct 2023 17:40:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697935252; x=1698540052; darn=debbugs.gnu.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=aqlXlyzKOFui1WxvXmxEgHjADYcHKUtzvUcjCrGJACw=; b=LeptqHBeK5yX6Mcgri6zPboHDsBOmSIWQmm/4PWExK50Adh+eTYvK+ZNnVns0XcteA AsstmaTNBq7XcwYJlwHOEy3DcworvuAscdhzGPDt0Nt2tf5IesONI16quMS1DtikGBs2 GT5+GOeAXCF99HjMqAr1Xfm4nqIAZ8+fMQ8PkfjpW1QcSmYyYhwcd3+wBMjOGac9HxTn C36P3fEI+psP8VffDYgmgrHbDCfOyVpgcVvGAzsiEQRQElC9O7ZKjN17LBer7TmrIh5j mcvK4naCKtsVnU/Xz92m4XoiTQFJNnFupx6Kxm7SxUeDc1M4PyRxTRSPJFZJBQIJdpp2 s79A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697935252; x=1698540052; h=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=aqlXlyzKOFui1WxvXmxEgHjADYcHKUtzvUcjCrGJACw=; b=urIaARU1BdbeNGDjHAqlojrRLzq93bQwu16fgTpXLkZaqulSzgbLHtB8eHVn9LXC8F w4hvOWMaJJfp3x6zgMINUJSMaJDFFF3fKygSl4mPWQRf3QonHOgw7A+xL1mqDE1gaIb0 NbeI9qGdM+mO+2Tn8vbdd5phoyjUYc0WY9gCtF3kTPjTL1lj9EYJYtdNwnM2x5EEgME8 4vyTa5+iDS3PDQO0xbszfQDZducNWvVfAuveu0kKKaQrgETYlhnWfj277jKPaqcE3p7R +pVFtndCbhg4v7QmB0wBbqvcfQzfxAm0aQWSXzbVv2G8g/VzZ0zmCJNH+gDfHPYb4MCw C/4w== X-Gm-Message-State: AOJu0YzYdhMBC/BhPmnw8pjpgSCVzXcuJmOIyHXf4dOGbT55tkM0fe1S eM3FWENDfMTiG5AkhnSup8pOSzK2c2zhqehVpZI= X-Google-Smtp-Source: AGHT+IEAyLDDhCA3wMQRB3YFeLyp401/BAVWKPLZ1lgi389Q9PdM97lc8QC/n4aN+vjs4Q/MK5I7UkLmuNiTickTJto= X-Received: by 2002:a05:6870:289b:b0:1e9:b2e2:8754 with SMTP id gy27-20020a056870289b00b001e9b2e28754mr7283558oab.2.1697935251921; Sat, 21 Oct 2023 17:40:51 -0700 (PDT) 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:272945 Archived-At: --0000000000008adeb10608435bf9 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Ok that makes sense, thanks for clearing that up for me, your fix looks good. I'm loving this package! On Sat, Oct 21, 2023 at 11:33=E2=80=AFAM Yuan Fu wrote: > > > > On Oct 20, 2023, at 2:22 PM, nvp wrote: > > > > That fixes the problem! > > > > However, the reason I initially put the reset inside the `(unless > (buffer-live-p treesit--explorer-buffer) ...)` > > in `treesit-explore-mode` was b/c it looked like there was an > optimization happening in > > `treesit--explorer-refresh` where it does this check > > > > ;; If we didn't edit the buffer nor change the top-level > > ;; node, don't redraw the whole syntax tree. > > (highlight-only (treesit-node-eq > > top-level treesit--explorer-last-node)) > > > > I don't know if that is something you'd want to keep, but just pointing > it out in case. I think > > the initial patch works as well, but still allows that check to work > when the explorer buffer hasn't > > been killed. > > Oh that=E2=80=99s fine, treesit-explore-mode always wipes everything and = start > from a clean slate. That optimization is for when the user moves point in > the source buffer when explore-mode is on. If you=E2=80=99d like to send = a patch > that does roughly what I did in the patch I sent, I=E2=80=99d love to mer= ge it. > Otherwise I can fix it myself, too. > > The initial patch could be a bit confusing to the readers since it sets > last-node twice, and it=E2=80=99s not clear why. > > Thanks, > Yuan --0000000000008adeb10608435bf9 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Ok that makes sense, thanks for clearing that up for me,= =C2=A0your fix=C2=A0looks good. I'm loving this package!

On Sat, Oct 21,= 2023 at 11:33=E2=80=AFAM Yuan Fu <= casouri@gmail.com> wrote:


> On Oct 20, 2023, at 2:22 PM, nvp <noah.v.peart@gmail.com> wrote:
>
> That fixes the problem!
>
> However, the reason I initially put the reset inside the `(unless (buf= fer-live-p treesit--explorer-buffer) ...)`
> in `treesit-explore-mode` was b/c it looked like there was an optimiza= tion happening in
> `treesit--explorer-refresh` where it does this check
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ;; If we didn't edit the = buffer nor change the top-level
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ;; node, don't redraw the= whole syntax tree.
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (highlight-only (treesit-node= -eq
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0top-level treesit--explorer-last-node)) >
> I don't know if that is something you'd want to keep, but just= pointing it out in case.=C2=A0 I think
> the initial patch works as well, but still allows that check to work w= hen the explorer buffer hasn't
> been killed.

Oh that=E2=80=99s fine, treesit-explore-mode always wipes everything and st= art from a clean slate. That optimization is for when the user moves point = in the source buffer when explore-mode is on. If you=E2=80=99d like to send= a patch that does roughly what I did in the patch I sent, I=E2=80=99d love= to merge it. Otherwise I can fix it myself, too.

The initial patch could be a bit confusing to the readers since it sets las= t-node twice, and it=E2=80=99s not clear why.

Thanks,
Yuan
--0000000000008adeb10608435bf9--