Giter VIP home page Giter VIP logo

Comments (21)

baqazan avatar baqazan commented on August 20, 2024 15

hey guys, I experienced similar issue and I believe I found the solution - find "editor.detectIndentation" setting and set it to 'false', it will cause to apply indents from settings rather than detect it based on the file you opened. After that just go to file and use Format Code feature, it worked for me and hopefully will work for you.

from editorconfig-vscode.

SEGEEK avatar SEGEEK commented on August 20, 2024 11

I am having a similar issue, I don't know if it is the same thing though. When I format an html file the editor config definition that says 'indent_style: space' is not respected. Oddly enough this only seems to affect html files.

I have a gif below that reproduces the issue, the leading spaces ('.') turn into tabs ('->'). I have the .editorConfig file open to the right, and you can see the status bar shows spaces:2 on the indent settings yet when I do the format it still converts to tabs.
format-to-tab

Also I am not sure this is an issue with editor config or vs code itself (not sure if editorconfig handles the formatting or if vs code does), I apologize if this is in the wrong place.

from editorconfig-vscode.

Adeynack avatar Adeynack commented on August 20, 2024 8

In my case, I disabled the JS-CSS-HTML-formatter and it started working. Hope it helps.

from editorconfig-vscode.

stoyaneft avatar stoyaneft commented on August 20, 2024 5

In my case the problem was caused by the Prettier - code formatter plugin, because it respects prettier configuration files before .editorconfig files. So if you have this plugin enabled and have a .prettierrc.json file, it will overwrite the .editorconfig settings.

In my case disabling formatOnSave for specific file types helped.

"editor.formatOnSave": true,
  "[json]": {
    "editor.formatOnSave": false
  }

from editorconfig-vscode.

Maximaximum avatar Maximaximum commented on August 20, 2024 1

Disabling all other extensions changes nothing and the issue still applies.

from editorconfig-vscode.

Maximaximum avatar Maximaximum commented on August 20, 2024 1

Have found a relevant issue for VS Code: microsoft/vscode#13563

from editorconfig-vscode.

itsmunim avatar itsmunim commented on August 20, 2024 1

@Adeynack you saved my day!

from editorconfig-vscode.

taikulawo avatar taikulawo commented on August 20, 2024 1

I have to disable EditorConfig.EditorConfig extention on vscode. It auto format files which cause cursor move suddenly even though editor.formatOnSave is false.

from editorconfig-vscode.

jednano avatar jednano commented on August 20, 2024

Can you be more specific? Which setting? What does your .editorconfig file look like? If you use an EditorConfig CLI utility like editorconfig, does the file in question have the expected settings?

from editorconfig-vscode.

qorbani avatar qorbani commented on August 20, 2024

I experience same issue! Here is my .editorconfig:

root = true

[*]
indent_style = space
indent_size = 4

end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
charset = utf-8

[*.md]
trim_trailing_whitespace = false

# Matches the exact files package.json and .travis.yml
[{package.json,.travis.yml}]
indent_style = space
indent_size = 2

[Makefile]
indent_style = tab

Here is my VSCode settings:

{
    "editor.fontSize": 14,
    "editor.renderWhitespace": "all",
    "editor.tabSize": 4,
    "editor.insertSpaces": true
}

When I open package.json file and use auto formating (OPTION+SHIFT+F) it correctly format based on my settings in .editorconfig, but then when I save the file, it fall into a loop. I think two rules fighting to override each other, one try to make it 2 space (.editorconfig) and the other one 4 space (VSCode settings)!

from editorconfig-vscode.

SamVerschueren avatar SamVerschueren commented on August 20, 2024

Actually that works perfectly fine here. I thought #76 was the thing causes the extension to fail, but it actually still works as expected on my system.

It might be caused by another plugin though. Care to disable all the installed plugins and only use this one? Just to make sure it's not another extension interferring with this one.

Also all the tests still pass (I know, not always accurate but still).

from editorconfig-vscode.

SamVerschueren avatar SamVerschueren commented on August 20, 2024

@SEGEEK I don't think this is an issue with EditorConfig but rather with the autoformatter. Try disabling this extension and save that file again. If it still fails, it's something else. Do you have other extensions installed? If so, try disabling them all and try formatting again. And if that still fails, open an issue in the VS Code repository.

from editorconfig-vscode.

Maximaximum avatar Maximaximum commented on August 20, 2024

I have to confirm that @SEGEEK's explanation is the most clear and correct. The issue seems to have nothing to do with file saving, but rather with using the "Format Code" feature.

from editorconfig-vscode.

SamVerschueren avatar SamVerschueren commented on August 20, 2024

The main question is, is it our extension or is it VS Code. Although less likely, it seems to me that it's a bug in VS Code as the EditorConfig settings are being applied correctly (hence the lower right corner). Don't have the time to look into it though but like I said, try without this plugin (and without any plugins) and try again.

from editorconfig-vscode.

Maximaximum avatar Maximaximum commented on August 20, 2024

If I uninstall EditorConfig, the issue still applies. Another important note is that the issue seems to apply only to working with *.html files, but not *.js or *.vb files

from editorconfig-vscode.

SamVerschueren avatar SamVerschueren commented on August 20, 2024

Do you have an html formatter extension installed or something? If not, just file an issue in the VS Code repository.

from editorconfig-vscode.

SEGEEK avatar SEGEEK commented on August 20, 2024

I believe @Maximaximum is correct ... just to try it out I disabled all of my extensions and it still occurred.

I appreciate you looking into this @SamVerschueren, sorry if I took you off task with the distraction, hopefully it will help others running into the same issue.

from editorconfig-vscode.

SamVerschueren avatar SamVerschueren commented on August 20, 2024

Glad we figured out the cause of this. Hopefully the VS Code team will fix this asap.

from editorconfig-vscode.

Adeynack avatar Adeynack commented on August 20, 2024

Well ... almost. The keyboard shortcut works, but then some config like insert_final_newline = true are ignored.

from editorconfig-vscode.

DaveSkender avatar DaveSkender commented on August 20, 2024

In my case, .editorconfig was ignored because it was at the root of my repo, but not at the root of the VS Code Folder I had open. I had assumed it would honor the "root" editor config in the repo, but it did not.

from editorconfig-vscode.

rqkohistani avatar rqkohistani commented on August 20, 2024

https://stackoverflow.com/questions/37826449/expected-linebreaks-to-be-lf-but-found-crlf-linebreak-style/71268059#71268059

from editorconfig-vscode.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.