roe / status-tab-spacing

atom package to display tab spacing in the editor
MIT License
2 stars 2 forks source link

editor.tabLength can be different from the tab length of the current Editor #2

Open felixkiss opened 10 years ago

felixkiss commented 10 years ago

All settings handled by atom.config are applied to all buffers on all open windows.

For example, if you change editor.fontSize, either on runtime by running atom.config.set('editor.fontSize', value) or by writing directly to config.cson, the change will be reflected immediately in all windows.

But not all developers want to use the same settings on every file. Personally, I prefer a tab size of 2 for HTML, Ruby, CoffeeScript but a tab size of 4 for Java or PHP. When I do projects for work that require me to have controller classes and view files open at the same time I need to set tabSize on the one specific Editor.

Today I installed a package that brings editorconfig.org to Atom: sindresorhus/atom-editorconfig

This package fulfills my requirement, because it uses Editor::setTabLength() instead of manipulating the global atom.config value.

status-tab-spacing subscribes to editor.tabLength and updates the status bar accordingly, which means it will report the wrong tab size when used with atom-editorconfig.

I am not saying this is your fault, and I am not aware of any method to subscribe to changes to Editor::getTabLength(). It is worth knowing and considering, hence I figured I'll give you a quick heads-up about the package.

Maybe one valid option would be to update the StatusTabSpacingView whenever the current buffer changes. Or the other package could trigger an event and you register to it. Or we send feedback to the Atom core team to take this into consideration and they provide a possibility to get notified whenever the Editor specific value changes.

Suggestions?

roe commented 10 years ago

I completely agree about different tab settings per file. I think a solution where the other package triggers an event would be nice, one thought is that I could subscribe to a more generic event so that any package that modifies Editor::setTabLength() would still work fine with this one.

Granted, if it was in the core functionality, that would make things even easier! So maybe it is worth pursuing that option as well...

Anyhow, thanks for the thoughts!