sindresorhus / editorconfig-sublime

Sublime Text plugin for EditorConfig - Helps developers maintain consistent coding styles between different editors
MIT License
1.77k stars 108 forks source link

Defaults for files without an .editorconfig file #32

Closed samselikoff closed 5 years ago

samselikoff commented 9 years ago

Editorconfig seems to be overriding my user preferences for new files with no .editorconfig file. In my Sublime preferences, I have

"tab_size": 2,
"translate_tabs_to_spaces": true

and yet new files start out with 4 spaces set as their default.

Is there any way to set this default within Editorconfig? I don't see any preferences under Preferences -> Package Settings.

sindresorhus commented 9 years ago

I don't see how that's possible as it requires a file path which it only get's from a saved file.

No code goes past this when there's no file path: https://github.com/sindresorhus/editorconfig-sublime/blob/79b466e0eee57ef0b8fa50b96350a60543778446/EditorConfig.py#L42

Sure there isn't some other plugin doing this?

samselikoff commented 9 years ago

Hm, that's strange. I uninstalled EditorConfig just to make sure, and it does seem to be responsible.

editorconfig-bug2

Let me know if there's any other info I can provide.

cobbweb commented 9 years ago

I'm seeing this too. I have tab_size: 2 and detect_indentation: false in my Sublime Settings, but when I open JavaScript file (in a project without an .editorconfig file), it defaults to 4 space indentation.

If I disable the plugin, restart and reopen the same file, the indentation is 2 spaces (like it should be)

kevinsalter commented 9 years ago

+1

When this EditorConfig plugin is active, it overrides Sublime's indentation auto-detection with its own defaults in the absence of an .editorconfig file. The screenshot below shows what happens when a file is selected in the sidebar and then opened in preview mode. You can see that Sublime is correctly trying to set the indentation to 4 spaces (arrow on the left), but is overridden (arrow on the right). Uninstalling the plugin restores Sublime's proper auto-indentation detection and settings.

indentation-error

GrayHatter commented 7 years ago

I lost >1h today trying to figure out what plugin was fucking with all my files.

God help you if you try to save Preferences.sublime-settings because it'll corrupt that file too.

Why isn't' the default, do nothing?

luwes commented 5 years ago

Experienced this issue too multiple times. If there is no .editorconfig file the plugin should indeed do nothing.

Seems to be caused by an .editorconfig file in your user folder ~/.editorconfig. If that is removed, it works like expected.

sindresorhus commented 5 years ago

Seems to be caused by an .editorconfig file in your user folder ~/.editorconfig. If that is removed, it works like expected.

That's how EditorConfig works. It searches upwards until it find a .editorconfig file.

sindresorhus commented 5 years ago

Closing as it's working per EditorConfig behavior. If you don't like the behavior, you should open an issue here: https://github.com/editorconfig/editorconfig-core-py