-
Notifications
You must be signed in to change notification settings - Fork 219
Description
Summary
When an LSP documention is closed and immediately reopened by the editor with completely different content (simulating an external file modification detected via file watchers), ty's response to the subsequent textDocument/semanticTokens/full response returns stale data from the previously opened version.
- Open a Python file with this content (Version A):
def calculate_sum(a):
# Version A: Basic math
return a
result = calculate_sum(5)- Request semantic tokens - server correctly responds with tokens for this content
- Close the file via
textDocument/didClose - Immediately reopen the same file via
textDocument/didOpenwith completely different content (Version B):
# Version B: Basic greeting
def say_hello():
print("Hello, World!")
say_hello()- Request semantic tokens again
The expectation is that the server returns semantic tokens matching the new content (Version B with say_hello function).
Instead, it returns the exact same semantic tokens data from the previous version (Version A with calculate_sum function).
The current workaround is to kill the ty session and connect again.
In the attached transcript.
-
Initial didOpen with Version A:
- Content:
"def calculate_sum(a):\n # Version A: Basic math\n return a\n\nresult = calculate_sum(5)\n"
- Content:
-
First semanticTokens/full[3] response:
- Result:
{"data":[0,4,13,7,1,0,14,1,2,1,2,11,1,2,0,2,0,6,5,1,0,9,13,7,0,0,14,1,11,0]}
- Result:
-
didClose followed by didOpen with Version B:
- Content:
"# Version B: Basic greeting\ndef say_hello():\n print(\"Hello, World!\")\n\nsay_hello()\n"
- Content:
-
Second semanticTokens/full[8] response:
- Result:
{"data":[0,4,13,7,1,0,14,1,2,1,2,11,1,2,0,2,0,6,5,1,0,9,13,7,0,0,14,1,11,0]} - ← IDENTICAL to response from step 2!
- Result:
The semantic tokens data is byte-for-byte identical despite the file content being completely different. This causes incorrect syntax highlighting in the editor.
Version
ty 0.0.9