-
Notifications
You must be signed in to change notification settings - Fork 12.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect semantic highlighting #56254
Comments
I didn't notice this before but this bug actually causes the file to not extend the {
"extends": "@electron-toolkit/tsconfig/tsconfig.json",
"include": [
"src/renderer/src/env.d.ts",
"src/renderer/src/**/*",
"src/renderer/src/**/*.svelte",
"src/preload/*.d.ts"
],
"compilerOptions": {
"verbatimModuleSyntax": true,
"useDefineForClassFields": true,
"strict": false,
"allowJs": true,
"checkJs": true,
"lib": ["ESNext", "DOM", "DOM.Iterable"]
},
"references": [{ "path": "./tsconfig.node.json" }]
} |
We'll definitely need a way to repro this. Strange. |
I remembered what template I was using, and it's enough to reproduce it out of the box: pnpm create @quick-start/electron app-test --template=svelte-ts
cd app-test
pnpm i
code . src/preload/index.d.ts
# wait for ts-server to be done and see weird stuff |
For me it goes a little farther than semantic highlighting. Can you try to do |
This seems to be because of the |
I have investigated this issue and the cause seems to be a problem where tsserver is attempting to retrieve the highlights for // app-test/src/index.d.ts
declare global {
interface Window {
electron: ElectronAPI
api: unknown
}
}
// app-test/src/index.ts
const api = {}
// app-test/tsconfig.json
{
"include": [
"src/*.d.ts"
],
"compilerOptions": {
},
"references": [{ "path": "./tsconfig.node.json" }]
}
// app-test/tsconfig.node.json
{
"include": ["src/**/*"],
"compilerOptions": {
"composite": true,
}
} The incorrect highlighting happens in I also noticed that the same thing happens with Info 122 request:
{
"seq": 33,
"type": "request",
"command": "documentHighlights",
"arguments": {
"file": "c:\\test-semantic-highlighting-no-electron\\app-test\\src\\index.d.ts",
"line": 1,
"offset": 9,
"filesToSearch": [
"c:\\test-semantic-highlighting-no-electron\\app-test\\src\\index.d.ts"
]
}
}
Info 124 response:
{"seq":0,
"type":"response",
"command":"documentHighlights",
"request_seq":33,
"success":true,
"body":[{"file":"c:/test-semantic-highlighting-no-electron/app-test/src/index.ts",
"highlightSpans":
[{"start":{"line":1,"offset":7},
"end":{"line":1,"offset":10},
"contextStart":{"line":1,"offset":1},
"contextEnd":{"line":1,"offset":15},
"kind":"writtenReference"
}]
}]
}
Info 125 request:
{
"seq": 34,
"type": "request",
"command": "completionInfo",
"arguments": {
"file": "c:\\test-semantic-highlighting-no-electron\\app-test\\src\\index.d.ts",
"line": 1,
"offset": 9,
"triggerCharacter": {
"id": "type-tree",
"range": {
"start": {
"line": 0,
"character": 8
},
"end": {
"line": 0,
"character": 8
}
},
"maxDepth": 6
}
}
}
Info 132 response:
{
"seq":0,
"type":"response",
"command":"completionInfo",
"request_seq":34,"success":true,
"body":{"isGlobalCompletion":false,
"isMemberCompletion":false,
"isNewIdentifierLocation":false,
"entries":[],
"__tsExplorerResponse":
{
"id":"type-tree",
"typeInfo":
{
"kind":"object",
"properties":[],
"indexInfos":[],
"symbolMeta":
{
"name":"api",
"flags":2,
"declarations":
[{
"location":
{
"fileName":"c:/test-semantic-highlighting-no-electron/app-test/src/index.ts",
"range":{"start":{"line":0,"character":6},"end":{"line":0,"character":9}}
}
}]
},
"id":"85,14,0"
}
}
}
}
Info 139 request:
{
"seq": 37,
"type": "request",
"command": "definitionAndBoundSpan",
"arguments": {
"file": "c:\\test-semantic-highlighting-no-electron\\app-test\\src\\index.d.ts",
"line": 1,
"offset": 8
}
}
Info 141 response:
{
"seq":0,
"type":"response",
"command":"definitionAndBoundSpan",
"request_seq":37,
"success":true,
"body":
{
"definitions":
[{
"file":"c:/test-semantic-highlighting-no-electron/app-test/src/index.ts",
"start":{"line":1,"offset":7},
"end":{"line":1,"offset":10},
"contextStart":{"line":1,"offset":1},
"contextEnd":{"line":1,"offset":15}
}],
"textSpan":{"start":{"line":1,"offset":7},"end":{"line":1,"offset":10}}
}
} |
I will look into this issue but this is such a bad configuration. There may be many places some of the assumptions going wrong here. |
π Search Terms
token mismatch, syntax highlighting
π Version & Regression Information
I tested with latest 5.0, 5.1, and 5.2 and it happens with all of them.
β― Playground Link
No response
π» Code
π Actual behavior
Code_tNdGogku8S.mp4
I have this file in my project that does this and it looks like a sourcemap / token map mismatch / offset or something.
π Expected behavior
The tokens should be mapping to their respective reflections like in this playground
Additional information about the issue
I can't reproduce this in another file it just keeps happening in this specific file in this specific project. I can reproduce it if I copy the project and install the dependencies, so if someone wants to investigate it I can add you to a repository with the code.
The text was updated successfully, but these errors were encountered: