Skip to content

Broken imports after moving file #1461

@dummdidumm

Description

@dummdidumm

Describe the bug

Two people have reported that moving a file results in a broken import

Reproduction

This happens when

  • TS plugin is enabled
  • a TS file is moved/renamed that is imported in both at least one TS and Svelte file

Then the $/getEditsForFileRename in our extension is fired, and afterwards the "update imports?" prompt of VS Code shows up. In some cases this doesn't hurt as the double update is idempotent, but not in all cases, so sometimes it messes up imports.

Not sure what the best way to fix this is. Don't do our import when the moved file is a TS file and it's imported in a Svelte file and the TS plugin is enabled (needs checks)? Somehow move our automatic import to the prompt as well and hope that this is somehow deduplicatable? Enhance the TS plugin to deduplicate on that end?

Edit: When deduplicating the import, the import is still broken, turns out it's the TS plugin which breaks the import, we need to adjust the range. Edit 2: Turns out that's not enough, sometimes the imports will still be broken (because they overwrite the same range which may have changed) - so we need to deduplicate this.

Expected behaviour

Flawless imports

System Info

  • OS: [e.g. Windows]
  • IDE: [e.g. VSCode, Atom]

Which package is the issue about?

Svelte for VS Code

Additional Information, eg. Screenshots

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    FixedFixed in master branch. Pending production release.bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions