question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Refactoring in VS Code destroys and/or falsifies .vue file!

See original GitHub issue

This is a very serious bug! It may also change logic without the developer noticing.

I tried to write specific steps for reproduction and at first the bug was reproducible. But as I went, the bug disappeared and I couldn’t understand why.

I had a file MyComposable.ts with code like this:

export type MyComposable { foo: number };
export function useMyComposable(): MyComposable { /*...*/ }

…and a file MyComponent.vue that used the composable:

<!--
bla
bla
bla
-->

<!--
foo
bar
-->

<script setup lang="ts">
import { useMyComposable } from "MyComponent.vue";

const myComposable = useMyComposable();

// [Code with `if`, `for` and comments referencing `myComposable.foo`.]
</script>

<template></template>

When I refactored foo from type MyComposable in MyComposable.ts by renaming it with <kbd>F2</kbd>, the spots in MyComponent.vue where the new name was inserted were wrong, they were shifted into different lines, between unrelated if and comment parts! When I removed the empty line in MyComponent.vue between --> and <!-- at the time the bug didn’t yet disappear, the inserting spots were influenced (shifted differently). At some point, the problem also happened when I renamed myComposable from MyComponent.vue.

Then, I did some things like duplicating MyComposable.vue into a new file Foo.vue. In that file, a new bug happened where renaming didn’t work at all and VS Code told me with a little bottom-right error pop-up: “Rename failed to apply edits”. I don’t exactly remember how it all took place exactly, but I also deleted Foo.vue in VS Code, closed VS Code, renamed MyComposable.vue to Foo.vue and reopened VS Code. Then, VS Code told me with a bottom-right warning pop-up: “The 2 extension(s) below, in workspace recommendations have issues: johnsoncodehk.volar (not found in marketplace) johnsoncodehk.vscode-typescript-vue-plugin (not found in marketplace)”. The still opened tab of MyComposable.vue didn’t show code in my monospace font, but a little message in a proportional sans-serif font; I think it said that the file didn’t exist anymore. When I opened Foo.vue, renaming also always failed with the message: “Rename failed to apply edits”.

Then, the bug disappeared and the warning pop-up is now shown on every start of VS Code. The bug also wasn’t reproducible anymore when going back in the bug test repository to earlier commits where the bug previously happened, also not after a fresh VS Code start with the earlier commit.

A third bug that happened some time in between the previously described actions was that I began to first mention the composable function useMyComposable(), clicked the light bulb icon and chose to add an import for it; but the import was added in an XML comment (between <!-- and -->). I could do this multiple times and every time an additional import line was added in the comment.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:9

github_iconTop GitHub Comments

2reactions
yoyo837commented, May 11, 2022

I mean https://code.visualstudio.com/docs/editor/settings-sync.

  1. Uninstall these two plugins;
  2. Make sure the synchronization succeeds once;
  3. Reinstall these two plugins;
1reaction
YoRollingcommented, May 17, 2022

I keep getting this prompt but don’t know why.

The 2 extension(s) below, in workspace recommendations have issues: johnsoncodehk.volar (not found in marketplace) johnsoncodehk.vscode-typescript-vue-plugin (not found in marketplace)

Check extensions.json in `${PROJECT_ROOT}/.vscode’. I got same warning, finally I found in there, delete them and waning went away.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I stop VS Code from totally destroying my code on save?
The solution was to uninstall vscode-JS-CSS-HTML-formatter which you can do by searching for the author, lonefy , in your packages. Share.
Read more >
Remote Development Tips and Tricks - Visual Studio Code
Visual Studio Code Remote Development troubleshooting tips and tricks for SSH, Containers, and the Windows Subsystem for Linux (WSL)
Read more >
Dev Containers Tips and Tricks - Visual Studio Code
Windows: Right-click on the Docker task bar item and select Settings. Go to Resources > File Sharing and check the drive(s) where ...
Read more >
Webview API - Visual Studio Code
In our extension's main file, we register the catCoding.start command and use it to show a ... Attempting to use a destroyed webview...
Read more >
Debug Node.js Apps using Visual Studio Code
json file located in your workspace's .vscode folder. An introduction into the creation and use of debugging configuration files is in the general...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found