Open onemen opened 6 months ago
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?
I’m seeing different behaviour.
(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?
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
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?
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
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
Even with the IntelliCode extension installed and activated, and the settings you posted I’m not seeing this issue.
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:
Thanks, — bb
I experienced this exact same issue and uninstalling the intellicode extension solved it.
I'm also having this issue and it's also connected to IntelliCode (v1.3.1) and editor.formatOnSave
.
Either disabling IntelliCode, mdx-analyzer (v1.8.9) or editor.formatOnSave
is a workaround.
Here are my settings, but I removed some obvious things like color settings or Java Path:
{
"[typescriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"material-ui-snippets.showNotesOnStartup": false,
"material-ui-snippets.importPaths": "second level",
"mui-snippets.importPaths": "second level",
"mui-snippets.showNotesOnStartup": false,
"npm.packageManager": "npm",
"editor.tabCompletion": "on",
"[jsonc]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[scss]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"jest.disabledWorkspaceFolders": [],
"jestrunner.codeLens": ["run", "debug", "coverage"],
"jest.autoRun": "off",
"jest.showCoverageOnLoad": true,
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit"
},
"files.eol": "\n",
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"editor.detectIndentation": false,
"[sql]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "mtxr.sqltools"
},
"workbench.startupEditor": "none",
"debug.autoExpandLazyVariables": false,
"editor.linkedEditing": true,
}
Unfortunately, I'm having this issue with Astro's VS Code extension, v2.13.1. Turning it off solves the issue. I feel like maybe it's not Intellicode's fault, but something related to what extensions do in general? I'm on MDX extension v1.8.9.
Edit 1: Astro's extension claims to support auto-imports, which I suspect might be causing the issue here.
Edit 2: okay, found the issue. Turns out I had source.organizeImports: explicit
in my editor.codeActionsOnSave
in my settings.json, which duplicated imports. Removing it fixed it. Not sure why.
Initial checklist
Affected packages and versions
vscode-mdx@1.8.0
Link to runnable example
No response
Steps to reproduce
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)