Indentation of .less files is crazy


#1

When I edit .less files they have a crazy indent of 27 characters. It uses a tab instead of spaces.

My .editorconfig includes:

[*.less]
indent_size = 2
indent_style = space
tab_width = 2

My Atom global settings include “Auto indent” and Tab length of 2, and Soft Tabs.

My “Language Less” (0.18.0) package has Auto indent and tab length of 2.

When I hit “tab” at the beginning of the line, I get 27 characters of indent, then 53 characters, then 79, 105, …

This happens on two computers (with their config shared over Dropbox).

Anyone have any idea what’s going on here or how I can go about rooting out the cause of the problem?


#2

Have you followed the suggestions in the Debugging document? Also, could you give the following information?

  • Which version of Atom are you using?
  • What OS and version are you running?
  • Can you reproduce the issue after completely exiting Atom and restarting using atom --safe?

#3

Thanks for the reply @leedohm

The issue persists through Atom 0.175.0, on Mac OS X 10.10.1. It is indeed reproducible after completely exiting and starting with atom --safe.

I would add that changing .editorconfig to the following seems to fix the error:

[*.less]
indent_size = 4
indent_style = tab
tab_width = 4

So I would hazard a guess that the problem is with the interpretation or implementation by editorconfig.

EDIT I was mistaken. The problem still occurs with tab/indent size in .editorconfig set as above. I really have no idea where to start then, I am afraid.


#4

Is this just *.less files or are other file types affected, as well? I have no idea what to do with the answer, but maybe someone else knows.


#5

Thanks @kgrossjo - It’s just *.less files as far as I can tell.

It’s completely bonkers, looks like the tab size is 27, and the auto-indenting functions cannot be turned off. It basically makes Atom unusable for editing .less files. It’s extremely odd. I can only imagine it is something buried in my config files, but I have rooted around at everything that makes sense to look at, to no avail.


#6

Try the following:

  1. Completely exit all instances of Atom
  2. Open a Terminal window
  3. Execute the command: mv ~/.atom ~/.atom-backup
  4. Start Atom with: atom --safe
  5. Create a new Less file in your home directory
  6. Edit the new file and attempt to reproduce the issue

#7

Thanks @leedohm.

Before exiting all instance of Atom and restarting, I tried copying my styles.less to another folder outside the project / .editorconfig.

The conditions for reproduction of the problem are slightly more narrow than I thought. In particular, the issue occurs only:

  1. In a file named styles.less in my project (i.e. not all .less files);
  2. for all changes made AFTER I open, modify, then save the .less.

Given that it is limited to one file, I am investigating whether the problem is due to an auto-indent that is computed based on the indents of prior lines (e.g. comments), since I noted in my styles.less file that some comments have significant indents. Will post with more info.

I will forego the --safe suggestion until I have vetted the above a bit further. Will be in touch again soon. Cheers.


#8

--safe helps us determine if the issue is due to a third-party package or Atom itself. Let us know if you need any other assistance or ideas.


#9

I have identified the following package as the culprit: https://atom.io/packages/auto-detect-indentation

Disabling the package solves the problem, and I have filed an issue with the package: https://github.com/jtokoph/auto-detect-indentation/issues/5

Thanks & Cheers.