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

all imports duplicate to the bottom on each save #407

Open
4 tasks done
onemen opened this issue Mar 1, 2024 · 10 comments
Open
4 tasks done

all imports duplicate to the bottom on each save #407

onemen opened this issue Mar 1, 2024 · 10 comments
Labels
🙉 open/needs-info This needs some more info 🤞 phase/open Post is being triaged manually

Comments

@onemen
Copy link

onemen commented Mar 1, 2024

Initial checklist

Affected packages and versions

vscode-mdx@1.8.0

Link to runnable example

No response

Steps to reproduce

  • In vscode upgrade to vscode-mdx@1.8.0
  • reload the vscode
  • open mdx file
  • save it

Expected behavior

lol

Actual behavior

result: another copy of all the imports in the file are duplicated to the bottom of the file

Runtime

Node v20

Package manager

pnpm

OS

Windows

Build and bundle tools

Other (please specify in steps to reproduce)

@github-actions github-actions bot added 👋 phase/new Post is being triaged automatically 🤞 phase/open Post is being triaged manually and removed 👋 phase/new Post is being triaged automatically labels Mar 1, 2024
@remcohaszing
Copy link
Member

Thanks for reporting! I'm pretty sure what causes this, so I'll fix it soon. As a workaround you should disable editor.formatOnSave.

But to be sure, can you share an MDX document to reproduce this?

@onemen
Copy link
Author

onemen commented Mar 1, 2024

https://github.com/onemen/tabmixplus-docs/blob/main/src/content/docs/index.mdx

@remcohaszing
Copy link
Member

I’m seeing different behaviour.

  1. Format Document With…MDX: Nothing happens.
  2. Format Document With…TypeScript and JavaScript Language Features: All lines are replaced with an empty line.
  3. Organize Imports → Imports are sorted

(1) is fine. (2) should really never happen. (3) works as expected. Disabling data.format for all mappings in the virtual code does not change this behaviour.

I’m going to need more info on this. What are your VSCode settings used for formatting?

@onemen
Copy link
Author

onemen commented Mar 2, 2024

this is my settings

{
"editor.formatOnPaste": true,
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"prettier.documentSelectors": ["**/*.astro"],
"prettier.ignorePath": "./config/.prettierignore",
"prettier.configPath": "./config/prettier.config.js",
"prettier.requireConfig": true,
"[astro]": {
"editor.defaultFormatter": "astro-build.astro-vscode"
},
"[markdown]": {
"editor.rulers": [100],
"editor.wordWrap": "wordWrapColumn",
"editor.wordWrapColumn": 100
},
"[mdx]": {
"files.trimTrailingWhitespace": false,
"editor.rulers": [100],
"editor.wordWrap": "wordWrapColumn",
"editor.wordWrapColumn": 100
},
"[yaml]": {
"editor.defaultFormatter": "redhat.vscode-yaml",
"editor.formatOnPaste": false,
"editor.autoIndent": "advanced"
},

"javascript.format.insertSpaceAfterOpeningAndBeforeClosingEmptyBraces": true,
"javascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": true,
"javascript.format.insertSpaceBeforeAndAfterBinaryOperators": true,
"javascript.format.insertSpaceAfterFunctionKeywordForAnonymousFunctions": true,
"typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": true,
"typescript.format.insertSpaceAfterOpeningAndBeforeClosingEmptyBraces": true,
"typescript.format.insertSpaceAfterKeywordsInControlFlowStatements": true,
"typescript.format.insertSpaceAfterFunctionKeywordForAnonymousFunctions": true,
"typescript.format.insertSpaceBeforeAndAfterBinaryOperators": true,
"editor.wordWrap": "on"
}

event when i set

"[mdx]": {
    "editor.defaultFormatter": "unifiedjs.vscode-mdx",
    "files.trimTrailingWhitespace": false,
    "editor.rulers": [100],
    "editor.wordWrap": "wordWrapColumn",
    "editor.wordWrapColumn": 100
  },

the issue remains the same. when i revert back to version 1.7.3 there is no problem

this is how the bottom of the file look like after saving it with version 1.8.0

</CardGrid>import { Card, CardGrid, LinkCard } from '@astrojs/starlight/components'
import DonateButton from '@components/DonateButton.astro'
import { downloadLink, releasesLink } from '@utils/helper.mjs'

the 3 import lines where copy from the top of the file

@remcohaszing
Copy link
Member

This is really helpful information, but I’m still not able to reproduce it with those settings.

I just released version 1.8.1. Can you check if that fixes the issue?

@onemen
Copy link
Author

onemen commented Mar 3, 2024

1.8.1 did not solve this issue.

I will try to start new folder with empty config and try to find the set of configuration and extension combination

I am on windows 11

@onemen
Copy link
Author

onemen commented Mar 3, 2024

The issue is probably some incompatibility with IntelliCode extension from Microsoft.

The problem solved as soon as I disabled IntelliCode

This issue only started on version 1.8.0, on version 1.7.3 using IntelliCode didn't cause any problem

@remcohaszing
Copy link
Member

Even with the IntelliCode extension installed and activated, and the settings you posted I’m not seeing this issue.

Copy link
Contributor

github-actions bot commented May 2, 2024

Hi! Thanks for taking the time to contribute! This has been marked by a maintainer as needing more info. It’s not clear yet whether this is an issue. Here are a couple tips:

  • Spend time framing the issue! The more time you put into it, the more we will
  • Often, maintainers respond with why for several back and forths; rubber duck debugging might help avoid that
  • Folks posting issues sometimes fall for xy problems: asking for a certain solution instead of raising the root problem

Thanks,
— bb

@stdavis
Copy link

stdavis commented May 9, 2024

I experienced this exact same issue and uninstalling the intellicode extension solved it.

stdavis added a commit to agrc/api.mapserv.utah.gov that referenced this issue May 23, 2024
stdavis added a commit to agrc/api.mapserv.utah.gov that referenced this issue May 23, 2024
stdavis added a commit to agrc/api.mapserv.utah.gov that referenced this issue May 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🙉 open/needs-info This needs some more info 🤞 phase/open Post is being triaged manually
Development

No branches or pull requests

3 participants