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

/*Ωignore_startΩ*/ in .svelte files #879

Closed
PatrickG opened this issue Mar 15, 2021 · 3 comments
Closed

/*Ωignore_startΩ*/ in .svelte files #879

PatrickG opened this issue Mar 15, 2021 · 3 comments
Labels
bug Something isn't working Fixed Fixed in master branch. Pending production release.

Comments

@PatrickG
Copy link
Contributor

PatrickG commented Mar 15, 2021

Describe the bug
When importing a store into a .svelte file, /*Ωignore_startΩ*/ gets inserted after the import statement.

To Reproduce

// store.ts
import { writable } from 'svelte/store';
export const store = writable({});
<script context="module" lang="ts">
  // Component.svelte
  import { store } from './store';
</script>

After saving the file, Component.svelte looks like this:

<script context="module" lang="ts">
  // Component.svelte
  import { store } from './store'; /*Ωignore_startΩ*/
</script>

Expected behavior
/*Ωignore_startΩ*/ should not be inserted

Edit
This only happens in context="module" script blocks.

@PatrickG PatrickG added the bug Something isn't working label Mar 15, 2021
@dummdidumm
Copy link
Member

I'm not able to reproduce this. Could specify in more details how to import the store, for example by posting a snippet with | marking where the cursor is before doing the import (I'm assuming you are talking about auto-import?) and where it is before doing the save.

@PatrickG
Copy link
Contributor Author

PatrickG commented Mar 17, 2021

It has nothing to do with the cursor, it is the formatter I think.
It happens when I save the file (format on save is active).

0IzcvPBHZ9
When the </script>-line "jumps" around I press CTRL+S.

Edit 1: Strange is, that it does not happen when i do "right-click -> Format Document".
Edit 2: The imports are not sorted when i do "right-click -> Format Document", so I think it has something to do with the import sorting.

@dummdidumm
Copy link
Member

Can reproduce this with the given snippet in the GIF and using the command "Organize Imports"

dummdidumm pushed a commit to dummdidumm/language-tools that referenced this issue Mar 19, 2021
Don't append the store declaration of imports that are stores right after the import. Instead, append it to the start of the render function. This way, imports are grouped without these declarations at the top, which makes "organize imports" behave correctly again and not put ignore-comments into the edits.
sveltejs#879
dummdidumm added a commit that referenced this issue Mar 19, 2021
Don't append the store declaration of imports that are stores right after the import. Instead, append it to the start of the render function. This way, imports are grouped without these declarations at the top, which makes "organize imports" behave correctly again and not put ignore-comments into the edits.
#879
@dummdidumm dummdidumm added the Fixed Fixed in master branch. Pending production release. label Mar 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Fixed Fixed in master branch. Pending production release.
Projects
None yet
Development

No branches or pull requests

2 participants