Skip to content
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

Deleting or pasting code sometimes causes messed-up highlighting and broken rename until reloading window #2534

Closed
CherryDT opened this issue Oct 12, 2024 · 6 comments
Labels
awaiting submitter bug Something isn't working

Comments

@CherryDT
Copy link

CherryDT commented Oct 12, 2024

Describe the bug

Sometimes when deleting or pasting code, all the syntax highlighting gets messed up (things get highlighted with different colors in the middle of a word, etc.), the "rename" operation doesn't work correctly anymore and overwrites random other things in the file with the new name instead of changing the places where the original name was used. This state gets fixed only by reloading the window.

It started only recently, maybe a week or so ago.

Reproduction

Don't know - it randomly happens when pasting code.

Expected behaviour

Normal syntax highlighting, normal "rename" behavior

System Info

  • OS: Windows with remote WSL1
  • IDE: VSCode 1.94.1

Which package is the issue about?

Svelte for VS Code extension

Additional Information, eg. Screenshots

image

@CherryDT CherryDT added the bug Something isn't working label Oct 12, 2024
@jasonlyu123
Copy link
Member

We'll need an actual reproduction to investigate. So please at least try to narrow down what the issue might be. Does this happen in a specific file? If so, does copying this file to any empty svelteKit project reproduce the problem? Is there a file in the directory with a similar name? Or maybe there is anything you did before you pasted any code? Like renaming the file?

@CherryDT CherryDT changed the title Pasting code sometimes causes messed-up highlighting and broken rename until reloading window Deleting or pasting code sometimes causes messed-up highlighting and broken rename until reloading window Oct 12, 2024
@CherryDT
Copy link
Author

CherryDT commented Oct 12, 2024

I realized it actually happens more frequently when deleting code rather than pasting.

It's very hard for me to reproduce reliably. It happens randomly on various files and various different areas of code, in different projects, approximately 1-2 times per hour. I was not renaming or creating or deleting files, just working on existing files.

I looked into the output pane a bit and I found two things that seemed relevant:

1: Under Svelte, there was this error:

Error: Debug Failure. False expression: Script kind should match provided ScriptKind:1 and sourceFile.scriptKind: 3, !entry: false
    at getDocumentRegistryEntry (/home/david/.vscode-server/extensions/svelte.svelte-vscode-109.1.0/node_modules/typescript/lib/typescript.js:140976:11)
    at releaseDocumentWithKey (/home/david/.vscode-server/extensions/svelte.svelte-vscode-109.1.0/node_modules/typescript/lib/typescript.js:141070:19)
    at registry.releaseDocumentWithKey (/home/david/.vscode-server/extensions/svelte.svelte-vscode-109.1.0/node_modules/svelte-language-server/dist/src/plugins/typescript/service.js:989:13)
    at getOrCreateSourceFileByPath (/home/david/.vscode-server/extensions/svelte.svelte-vscode-109.1.0/node_modules/typescript/lib/typescript.js:149935:30)
    at Object.getOrCreateSourceFile (/home/david/.vscode-server/extensions/svelte.svelte-vscode-109.1.0/node_modules/typescript/lib/typescript.js:149919:14)
    at /home/david/.vscode-server/extensions/svelte.svelte-vscode-109.1.0/node_modules/typescript/lib/typescript.js:149840:42
    at Object.getSourceFileWithCache [as getSourceFile] (/home/david/.vscode-server/extensions/svelte.svelte-vscode-109.1.0/node_modules/typescript/lib/typescript.js:124075:24)
    at findSourceFileWorker (/home/david/.vscode-server/extensions/svelte.svelte-vscode-109.1.0/node_modules/typescript/lib/typescript.js:126536:23)
    at findSourceFile (/home/david/.vscode-server/extensions/svelte.svelte-vscode-109.1.0/node_modules/typescript/lib/typescript.js:126452:20)
    at processImportedModules (/home/david/.vscode-server/extensions/svelte.svelte-vscode-109.1.0/node_modules/typescript/lib/typescript.js:126852:11)

2: Under Window, there was this warning:

2024-10-12 17:30:21.267 [warning] Overlapping semantic tokens detected at lineNumber 52, column 73

Is there a way I could get more debug output for you to review?

@jasonlyu123
Copy link
Member

The error sounds like you added lang="ts" to a svelte file that wasn't included in your tsconfig but was loaded because it was imported. But I can't reproduce the error. Can you reproduce it reliably with the information? If you can reliably reproduce it, please try to create a reproduction repository with the info. Else at least with your tsconfig/jsconfig and project structure.

@jasonlyu123
Copy link
Member

Let's track the error in #2538 since there is a reproduction for it. I currently can only reproduce the error but not the out-of-sync issue here. We'll see if it is also fixed once #2538 is fixed.

@jasonlyu123
Copy link
Member

I can reproduce the out-of-sync now with the reproduction of #2538, so I'm closing in favour of it.

@CherryDT
Copy link
Author

CherryDT commented Oct 30, 2024

Thank you - I was not able to create a reproduction without keeping significant parts of the projects intact that I couldn't share. It did happen on several projects but they were all larger customer projects.

(I certainly did not use lang="ts" though, I am not using TypeScript at all.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting submitter bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants