Formatting with VSCode adds a tab instead of 2 spaces

Hi, I'm experiencing a weird behavior in VSCode. I'm formatting a new Typescript file however it adds a tab for indentation instead of 2 spaces, but formatting an existing file works. I have setup this config under deno.json: "fmt": { "indentWidth": 2 } However running deno fmt myFile.ts works in both cases (old and new files). Is it suppose that Deno VSCode extension uses deno fmt under the hood? I have attached a video.
3 Replies
Deno AI Helper
Deno AI Helper•4mo ago
Hello! 🦕 It sounds like you're encountering an issue where the Deno VSCode extension isn't respecting the deno.json configuration for new TypeScript files. The Deno VSCode extension should indeed use deno fmt under the hood for formatting. The documentation states that the formatter can be customized using a configuration file, and you've correctly set the indentWidth to 2 in your deno.json configuration file. This should apply to all files when you run deno fmt from the command line. Here are a few steps you can take to troubleshoot the issue: 1. Ensure Deno Extension is Enabled: Make sure that the Deno extension is enabled for the workspace where you're working and that it's the latest version. 2. Check Workspace Settings: Sometimes, VSCode workspace or user settings can override the Deno settings. Check your .vscode/settings.json for any conflicting formatter settings. 3. Restart VSCode: Sometimes, changes in the configuration files require a restart of VSCode to take effect. 4. Check for Conflicting Extensions: Other installed extensions, especially those related to formatting, might conflict with the Deno extension. Try disabling other formatter extensions to see if that resolves the issue. 5. Validate Deno is Active: Ensure that Deno is active for the file you're editing. You should see "Deno" in the bottom right status bar of VSCode when you have a TypeScript file open. If after trying these steps the issue persists, it might be a good idea to report the issue to the Deno VSCode extension repository so that the maintainers can investigate further. They might be aware of the issue or could provide additional support. Remember to include as much detail as possible when reporting the issue, such as the version of the Deno
Deno AI Helper
Deno AI Helper•4mo ago
extension you're using, your deno.json configuration, and the behavior you're experiencing, along with the video you mentioned. This information will help the maintainers diagnose the problem more effectively.
Santiago Aguilar Hernandez
From https://github.com/denoland/deno/pull/24181 It is using VSCode default width and space/tab option. So setting the space directly will work:
No description