jtokoph / auto-detect-indentation

Auto detect indentation of files in Atom
MIT License
39 stars 6 forks source link

Not working in Atom 1.12.* #25

Open nahuelhds opened 7 years ago

nahuelhds commented 7 years ago

Yesterday I've updated to Atom 1.12.0 and this plugin doesn't work anymore.

I'm on Windows 10 64 bits.

Thanks!

mtorromeo commented 7 years ago

Same here with Atom 1.12.2 on Linux (I don't think the platform is relevant). It seems like every time you select an editor tab atom reapplies its own indentation settings.

mtorromeo commented 7 years ago

I noticed that whatever sindresorhus/atom-editorconfig is doing, it is not affected by Atom's update and when I work on projects with a .editorconfig file the indentation settings are always respected.

You may want to take a look at how it is applying the settings.

danfuzz commented 7 years ago

Maybe this is the same as https://github.com/jtokoph/auto-detect-indentation/issues/23, which I filed a few weeks ago. See also https://github.com/atom/atom/issues/13141 which I filed on Atom core.

tofof commented 7 years ago

+1

forivall commented 7 years ago

I'm investigating a fix for this at https://github.com/forivall/auto-detect-indentation/tree/pane-focus-change-fix . I still need to update it so that the indentation is only automatically detected on first open, and then stored in a weak map.

Also, there needs to be coordination with atom-editorconfig, since both packages will load the indentation settings if they have no settings of their own to set. This will override the other's setting, depending on which gets invoked last.

Specifically, https://github.com/jtokoph/auto-detect-indentation/blob/06b3abdf/lib/indentation-manager.coffee#L75 and https://github.com/sindresorhus/atom-editorconfig/blob/6dd0a62d/index.js#L143 conflict with each other.

I'm thinking of: (A): see if everything works fine without manually setting the default settings (B): creating an "editor settings" provider/consumer like with https://github.com/steelbrain/linter, so that both this and editorconfig will provide editor settings, and if one doesn't provide settings, then the consumer tries the next. (C): include the automatic detection directly in editorconfig, and explicitly state that they don't work together.

adamshaylor commented 7 years ago

I tried disabling atom-editorconfig. It doesn’t appear to be related.

forivall commented 7 years ago

Yup, did some more digging, and it's also because https://github.com/atom/atom/blob/18ddcf9/src/text-editor-registry.js#L327 (called by https://github.com/atom/atom/blob/18ddcf9/src/text-editor-registry.js#L154) is run after auto-detect-indentation sets the indentation, and the .

Although, appearances can be deceiving. Editorconfig also does conflict, but the text-editor-registry conflict is more important. So I'll look into the text-editor-registry conflict first.

It could mean monkey patching something in text-editor-registry, and if both editorconfig and auto-detect-indentation would have to make use of a monkey patch, I'd want them to use the same monkey patch. (so I'd still use one of the above solutions)

Or, just delaying after TextEditorRegistry's initialPackageActivationPromise. I'll have to experiment later.

PS ugh, promise microtask queue. blink's async stack trace is my only hope screen shot 2016-12-02 at 11 53 52 am

villermen commented 7 years ago

A workaround for this issue while it is being addressed:

Save (Ctrl+S) after opening a file.

Saving also triggers indentation detection, and will happen after the promises this way.

ddelrio1986 commented 7 years ago

I am noticing the same behavior. When I save the file it correctly detects the indentation.

parasyte commented 7 years ago

My current workaround is defining language-specific indentations. E.g. in the package settings for language-yaml and language-json, I've set Tab Length to 2.