Tabs still don't work. Package related?


#1

I cannot get Atom to use tabs. Regardless of whether Soft Tabs is on or off, even if the entire document has leading tabs and zero leading spaces, starting a new line causes spaces to be inserted. Pressing the Tab button also causes spaces to be inserted.

Related topics/support items seem to be related to wrapping and new line bugs, but this occurs even when pressing the Tab button on the keyboard, which I hope is not related to wrapping code…!

Surely the “Soft Tabs” setting actually does something, but at the moment all I can see is that in every single instance where a Tab should appear, spaces are being inserted. It’s driving me (and my code reviewers) crazy!

Is there a special setting somewhere to say “no, I only want tabs, never insert leading spaces, all of the time, without exception?” I don’t want any “smart” behavior. I want tabs…not spaces.

(Special thanks to the Tabs-to-Spaces package for helping me keep my sanity! :smiley: )


#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?
  • Do you have the React editor enabled?
  • Can you reproduce the issue after completely exiting Atom and restarting using atom --safe?

#3

Yes, I have. There is no relevant debug/error output, and as far as I can tell nothing seems to be commandeering the addTabStop method which I’d assume is the place to look.

  • 0.117.0
  • Happens on both Mavericks and Yosemite
  • Happens with React both enabled and disabled
  • Yes

FWIW this happens when editing code in every language I’ve used in Atom (JavaScript, CSON/JSON, HTML, C++, C#, Boo…)


#4

I just noticed I’m a version behind. I updated to 0.118.0, and it too has the same issue.


#5

Can you file a bug on Atom Core and link it back here? If possible, include a GIF of what is happening.


#6

So, the issue is twofold.

First, the autodetection function usesSoftTabs uses this logic:

  1. Does any line start with whitespace? If so,
  2. Is character 0 of that line not a tab?

In the case where there is a non-tab whitespace, it assumes that soft tabs are wanted.

For some reason, the first character of my file is being reported as U+FEFF, or ZERO WIDTH NO-BREAK SPACE. This is not in the file, I confirmed using od.

Anyway, the root problem IMHO is that the function checks for “tab is not present” instead of “space is present,” since that’s the definition of Soft Tabs(right?).

A good enhancement would be an option to disable that auto detection in the first place, but until then, I’ve fixed the logic, and submitted a pull request:


#7

This is the Unicode Byte-Order Mark or BOM. I don’t know why whatever library Atom uses is inserting it into the stream, but that is what it is.