-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Interacts poorly with per-type indentation settings #23
Comments
(I've been doing some investigation.) I know this isn't a complete solution, but it looks to me like part of the problem is that there is a way for the spacing settings to get updated other than the two methods that this package overrides. Specifically, originalUpdate = editor.update
...
# Trigger "did-change-indentation" event when indentation is changed.
editor.update = (params) ->
value = originalUpdate.call(editor, params)
if (params.softTabs isnt undefined) or params.tabLength
@emitter.emit 'did-change-indentation'
value |
A little more info: Near as I can tell, the actual settings race is between this package and this bit from for (const [settingKey, paramName] of EDITOR_PARAMS_BY_SETTING_KEY) {
this.subscriptions.add(
this.config.onDidChange(settingKey, configOptions, ({newValue}) => {
this.editorsWithMaintainedConfig.forEach((editor) => {
if (editor.getRootScopeDescriptor().isEqual(scopeDescriptor)) {
editor.update({[paramName]: newValue})
}
})
})
)
} One of the so-named ['editor.tabLength', 'tabLength'], |
Just one more note before I give up on this for the day. I have a really janky workaround, which mostly works. In indentation = IndentationManager.autoDetectIndentation editor
IndentationManager.setIndentation editor, indentation, true to this: # Wait just a moment to allow for the default value to get set up by the
# per-type configuration code. Then run the detector.
soon = ->
indentation = IndentationManager.autoDetectIndentation editor
IndentationManager.setIndentation editor, indentation, true
setTimeout soon, 250 The problem I've noticed is that this doesn't work when restarting Atom, when saved window state gets restored. I haven't figured out why that is. In any case, I hope all this commentary is useful to you. |
BTW, the referenced bug was closed as "fixed in 1.12," but it looks to me like the problem still exists in that version. |
When one has a
config.cson
that specifies per-type indentation, my expectation would be that the config settings are the default for new files and are responsible for the tab width on tabbed files, but that this package overrides these settings based on what is detected. That doesn't appear to be what happens. Instead, it looks like this package gets overridden by the per-type setting.Steps To Reproduce
Put the following in your
config.cson
:Open up a
.js
file with blatant two-space indentation.Expected Results
The editor is set to two-space indentation.
Actual Results
The editor is set to eight-space hard tab indentation. If you watch carefully, you can sometimes see the indentation status briefly flash "2 Spaces" before getting thwacked to "Tabs (8 wide)".
The text was updated successfully, but these errors were encountered: