language-tools
language-tools copied to clipboard
Other statements sandwiched between imports get removed when doing organize imports
Describe the bug
See below
Reproduction
<script lang="ts">
import { assets } from '$app/paths';
const foo = `${assets}/foo`;
import { browser } from '$app/env';
</script>
{#if browser}
<div />
{/if}
After running organize imports the const foo statement gets removed, the output becomes
<script lang="ts">
import { browser } from '$app/env';
import { assets } from '$app/paths';
</script>
{#if browser}
<div />
{/if}
Expected behaviour
Doing the same thing in a TS file the output is:
import { browser } from '$app/env';
import { assets } from '$app/paths';
const foo = `${assets}/foo`;
so I'd expect the same.
System Info
- OS: Windows
- IDE: VSCode
- Extension version: v105.20.0
Which package is the issue about?
svelte-language-server
Additional Information, eg. Screenshots
No response
For anyone facing this when organising imports in bulk,
I used find with import .*\n+\s*(export|const|let).*\n*\s*import to identify places where this happened, moved them manually out of the import block before doing a bulk organise.
Always run a check afterwards as there could be other statements apart from export, const, let.