From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dario Gjorgjevski Newsgroups: gmane.emacs.bugs Subject: bug#72696: Track-changes errors out when file is overwritten using Node.js's fs.writeFile (at least on macOS) Date: Thu, 22 Aug 2024 13:19:39 +0200 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="28150"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 72696@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Aug 22 13:22:40 2024 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 1sh5tn-00077I-Ak for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 22 Aug 2024 13:22:39 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sh5tU-0007gF-7l; Thu, 22 Aug 2024 07:22:20 -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 1sh5tR-0007g1-HP for bug-gnu-emacs@gnu.org; Thu, 22 Aug 2024 07:22:17 -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 1sh5tQ-0002sE-6e for bug-gnu-emacs@gnu.org; Thu, 22 Aug 2024 07:22:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=Date:From:In-Reply-To:References:MIME-Version:To:Subject; bh=WowPsqrkldlD+2VIfy6lY1NsYgS31R4Og6Hipn1AdBo=; b=G058IzN2oNvVdhMMWD4zmWUn4t7Jut1o3AzRNec6dNgvoD7jVVRUXvxSb1OlZL7NEc7x7c20nVJqKIyLD8Euxpn0m9yQJ1UpYr2wQfKqzmtE7RbQEoWyPdwXfcAsBcISv0eYAMub2mEeJ95zN8Yh1Yu2iBusEbs4ZK5wtZoYlTel/LLedccOlb3UaXv7Nkp8QvhadPe4dMgojRAVHhicrHGQaS0XVZD0SQOCD7c2B8zI22cEdec7lAxyw/ZB3f+Fwvcpq4yIrrnp5hmgb6QGgJKbDD6GOiFciWxQjyE3fscFnCYJ29UTjLCAe8frVL911Ke64prbIKW50Kml/QgDuw==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sh5u9-00071h-RM for bug-gnu-emacs@gnu.org; Thu, 22 Aug 2024 07:23:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Dario Gjorgjevski Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 22 Aug 2024 11:23:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 72696 X-GNU-PR-Package: emacs Original-Received: via spool by 72696-submit@debbugs.gnu.org id=B72696.172432573226934 (code B ref 72696); Thu, 22 Aug 2024 11:23:01 +0000 Original-Received: (at 72696) by debbugs.gnu.org; 22 Aug 2024 11:22:12 +0000 Original-Received: from localhost ([127.0.0.1]:36890 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sh5tL-00070L-VV for submit@debbugs.gnu.org; Thu, 22 Aug 2024 07:22:12 -0400 Original-Received: from mail-lj1-f177.google.com ([209.85.208.177]:50237) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sh5tI-0006zt-Ph for 72696@debbugs.gnu.org; Thu, 22 Aug 2024 07:22:10 -0400 Original-Received: by mail-lj1-f177.google.com with SMTP id 38308e7fff4ca-2f3ce5bc7d2so7084721fa.0 for <72696@debbugs.gnu.org>; Thu, 22 Aug 2024 04:21:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724325617; x=1724930417; darn=debbugs.gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=WowPsqrkldlD+2VIfy6lY1NsYgS31R4Og6Hipn1AdBo=; b=IFf5yZY0KDLkBbC3PZdFAco6iUB1L/KWFfmhYTB9vIOAtTNSI3gdhj84UHE8d2cal2 Vo156XdjLsXAakH/1Br0g6vcnLW+joMPLgd5376TBnYKDIrmz0baddPFc/mVbjkqikPI 8ahmJjdbv8m3aOacAFwhOD8X9rawb7f2jkxyy795zACb6w6FqUO68YmwkSzeWa4B+VrR KKuseQOywE2pPIKhssYR+y/mN22lcDlwb8fLlDcA288KkYcLST0KAf+K8XFvZDlAeWOe SmSX4jVPez5K7Ss/86rmJRicz3PiS2i/NQ0LjbEutmjmSRvmDR6Bq3jZEVq7Enr201Oj 041A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724325617; x=1724930417; 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=WowPsqrkldlD+2VIfy6lY1NsYgS31R4Og6Hipn1AdBo=; b=eaAJiX0nbCZo2ngX7NTiHfrx3/4vufVBocLPeB07jknnYVBT3Q99KBGSFvc1B2ONre 5YegnPLAACoQce8syQua8Rl2w4y0kklFf5GVFVQS8TvqDTBlyD9iDebHQOSijTc7rVDn fQFCd9CR9HqyYemF+3Wgc2OSmOKxr4xbpmV5kxMfV0C/zGBRC6gpBGTY4K21u3/a2So6 Dt4clt1XmMdO4TCZyOj8PknJqPFKzWIn1duvvdX1C736AZloR2HYIt+k2pxeuhuVvtaw M+oEOr9KV2Fh5UYD7ABu5hvf40eK4B2aWszIZ25Y64EGAsWPGiZ3PJzgEtuxDpFK22pc jItA== X-Gm-Message-State: AOJu0YzIJm/Giz8Avx2/vV99CYEb/W85V8kr/hp3w1bOpAqf4ssz3GzQ R32oXj4JCd01a7n0SBl2i6SUvtMzYvbhSNj5OdBt+sNAtBEdeemdBS2lctTIRCZ5TULEFJr4cXk JE/lj5G+I1tulvU3ayFBgQ84b0GuVqInE X-Google-Smtp-Source: AGHT+IGN+77qunILaxU4csZESv3KZ4lv+dn10d+etOrB0xvbfOiAe4xjfuJHyHG08WpcF3HkwU1uEt2Xjx0hfIhNq20= X-Received: by 2002:a05:651c:1025:b0:2f3:ee44:c6de with SMTP id 38308e7fff4ca-2f405d9eee5mr8625711fa.27.1724325616118; Thu, 22 Aug 2024 04:20:16 -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:290525 Archived-At: Hi, Stefan, On Tue, Aug 20, 2024 at 2:15=E2=80=AFPM Stefan Monnier wrote: > > >> - Eglot errors out. This should definitely not happen and seems like > >> a regression. Restarting Eglot should definitely not be needed. > >> Could you clarify what you mean by Eglot erroring out and why > >> restarting it is necessary? > > Eglot gets in a weird state and begins reporting erroneous data to the > > LSP server. > > Can you give any further details? Consider a Python file with the following contents (including a trailing newline): from urllib import urlretrieve local_filename, headers =3D urlretrieve('http://python.org/') Using the Pyright LSP server, Eglot correctly reports that: Pyright [reportAttributeAccessIssue]: "urlretrieve" is unknown import s= ymbol Now, rewrite the file using Node.js as instructed above so that its contents become (again, including a trailing newline): from urllib.request import urlretrieve local_filename, headers =3D urlretrieve('http://python.org/') Eglot now weirdly reports that: Pyright [reportMissingImports]: Import "urllib.request.request" could not be resolved Somehow it thinks that the ".request" part appears twice in a row. Here is the relevant communication between Eglot and Pyright: [jsonrpc] e[13:00:21.956] --> textDocument/didOpen { "jsonrpc": "2.0", "method": "textDocument/didOpen", "params": { "textDocument": { "uri": "file:///Volumes/workplace/playground/test.py", "version": 0, "languageId": "python", "text": "from urllib import urlretrieve\nlocal_filename, headers =3D urlretrieve('http://python.org/')\n" } } } [jsonrpc] e[13:00:22.617] <-- textDocument/publishDiagnostics { "jsonrpc": "2.0", "method": "textDocument/publishDiagnostics", "params": { "uri": "file:///Volumes/workplace/playground/test.py", "version": 0, "diagnostics": [ { "range": { "start": { "line": 0, "character": 19 }, "end": { "line": 0, "character": 30 } }, "message": "\"urlretrieve\" is unknown import symbol", "severity": 1, "code": "reportAttributeAccessIssue", "source": "Pyright", "codeDescription": { "href": "https://github.com/microsoft/pyright/blob/main/docs/configuration.md#repor= tAttributeAccessIssue" } } ] } } [jsonrpc] e[13:00:26.362] --> textDocument/didClose { "jsonrpc": "2.0", "method": "textDocument/didClose", "params": { "textDocument": { "uri": "file:///Volumes/workplace/playground/test.py" } } } [jsonrpc] e[13:00:26.364] --> textDocument/didOpen { "jsonrpc": "2.0", "method": "textDocument/didOpen", "params": { "textDocument": { "uri": "file:///Volumes/workplace/playground/test.py", "version": 0, "languageId": "python", "text": "from urllib.request import urlretrieve\nlocal_filename, headers =3D urlretrieve('http://python.org/')\n" } } } [jsonrpc] e[13:00:26.366] --> textDocument/didChange { "jsonrpc": "2.0", "method": "textDocument/didChange", "params": { "textDocument": { "uri": "file:///Volumes/workplace/playground/test.py", "version": 1 }, "contentChanges": [ { "range": { "start": { "line": 0, "character": 11 }, "end": { "line": 0, "character": 11 } }, "rangeLength": 0, "text": ".request" } ] } } [jsonrpc] e[13:00:26.629] <-- textDocument/publishDiagnostics { "jsonrpc": "2.0", "method": "textDocument/publishDiagnostics", "params": { "uri": "file:///Volumes/workplace/playground/test.py", "version": 1, "diagnostics": [ { "range": { "start": { "line": 0, "character": 5 }, "end": { "line": 0, "character": 27 } }, "message": "Import \"urllib.request.request\" could not be resolved", "severity": 1, "code": "reportMissingImports", "source": "Pyright", "codeDescription": { "href": "https://github.com/microsoft/pyright/blob/main/docs/configuration.md#repor= tMissingImports" } } ] } } As far as I can see, the testDocument/didChange request should not be there. The rewrite seems to have triggered a textDocument/didClose followed by a textDocument/didOpen, so the erroneous textDocument/didChange ended up making the LSP server think the ".request" part appears twice in a row. Best regards, Dario