Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Sometimes tab inserts spaces, even with soft tabs off #11

Closed
chamons opened this issue Mar 11, 2014 · 41 comments
Closed

Sometimes tab inserts spaces, even with soft tabs off #11

chamons opened this issue Mar 11, 2014 · 41 comments
Labels

Comments

@chamons
Copy link

chamons commented Mar 11, 2014

http://discuss.atom.io/t/sometimes-tab-inserts-spaces-even-with-soft-tabs-off/3976

@WooD1k
Copy link

WooD1k commented Mar 16, 2014

Please fix it!

@chamons
Copy link
Author

chamons commented Mar 17, 2014

@tm1000
Copy link

tm1000 commented Mar 26, 2014

"Is your use case that you want to open a buffer containing soft tabs and still insert hard tabs? Or vice versa?"

Yes because in PHPDOC Block format the comments are sometimes pushed forward a little with a single space (for alignment) like so:

/*
*
Atom interprets that as "oh you have a space so everything will be spaces" which is annoying if the actual file is hard tabs.

@sethburtonhall
Copy link

Please fix. This is very annoying when working with a team.

@iandotkelly
Copy link

I hate to add a +1, but this doesn't seem to be going anywhere and I'm going to have to go back to Sublime Text 2 when working on a js project that uses tabs by default, and FYI it absolutely seems to relate to the use of PHP/Javadoc style block format being used, that have a leading space in them.

@maurociancio
Copy link

+1

@lord2800
Copy link

+1 from me as well. This annoys me to no end.

@sookcha
Copy link

sookcha commented May 20, 2014

+1

@holzmann
Copy link

+1
Switched back to Sublime Text 3 because of this behavior.

@mer10z
Copy link

mer10z commented May 22, 2014

I'm also having this problem with the javascript editor on Ubuntu. I can't copy and paste tabs, and when I press the tab key to further indent a line that is already indented with tabs, it adds the new indent in spaces plus enough spaces to eqaul the tab amount, as if the tabs weren't there, ie with tabs set to 2 spaces a press of the tab key changes \t\t to \t\t......

@maurociancio
Copy link

Yes @mer10z it's very annoying. The editor works well when there are no comments in the code, as someone pointed earlier.
For example, if i have:
/**

  • comment with spaces

*/

And you try to use tabs, you get spaces.

@ghost
Copy link

ghost commented May 27, 2014

+1

@nathansobo
Copy link
Contributor

Can someone post a file that reproduces this issue? I would have thought a previous fix that ignores comment blocks for purposes of determining the tab setting would fix this: https://github.com/atom/atom/blob/master/src/editor.coffee#L326

Are you guys having issues editing files with mixed tab styles?

@probablycorey
Copy link

This is related to atom/atom#2045.

@tm1000
Copy link

tm1000 commented May 27, 2014

@nathansobo
For me this issue has been completely resolved with something you fixed within the .90 - .99 releases so I haven't run across any file that has the issue. I wasn't sure if it was a fluke or not until your comment right now.

@iandotkelly
Copy link

@nathansobo
The problems that I have are:

  1. (This problem) Where it inserts spaces instead of tabs even though I have soft-tabs off
  2. When I start atom, some files come up with 2 space tabs, even though I have it set to 4
  3. I regularly see tab stops not lining up on adjacent lines.

You can find an example file that I see exhibiting problem 1 here:

https://raw.githubusercontent.com/iandotkelly/atomissue/master/sample.js

If I select any line here and hit tab, it inserts 4 spaces (or two spaces if its also exhibiting problem described above). I have atom@0.99 installed - I have soft tabs off.

Thanks for showing an interest in my issue - atom would be fantastic if it wasn't for these issues I am seeing. Should I just nuke atom and start again?

@tm1000
Copy link

tm1000 commented May 27, 2014

@iandotkelly The file works fine for me in .99. I am able to tab anywhere and it will use tabs instead of spaces.

Additionally I have been going back and fixing all of the files atom forced spaces upon me in and they are also using tabs now

@iandotkelly
Copy link

@tm1000 - I guess I will be removing Atom and re-installing then - thanks for trying to replicate my issue though, most appreciated!

@iandotkelly
Copy link

@tm1000 - so I deleted Atom (from the finder) and deleted my ~/.atom folder and re-installed. Still have the problem!

@iandotkelly
Copy link

@nathansobo & @tm1000 - if I delete the comment block from my code, save the file and reopen it - tabs start working. If I then replace the comment block back into the code - the soft-tabs behaviour comes back.

I've deleted Atom and downloaded .99 again, and deleted ~/.atom - which is confirmed by me losing all my packages, themes etc.

I have a straightforward setup on my Mac - OSX Mavericks, and I run node.js for development.

@tm1000
Copy link

tm1000 commented May 27, 2014

@iandotkelly Tabs vs Softtabs is determined when the file is first opened (or at least it was when @GameGamer43 did the PR) so I saved your file and then opened it from Atom. I didn't copy and paste anything

When I copy and paste the comment block all spaces are removed from the comment block so it's rather hard for me to test that element, this could be the result of a plugin as I have several that deal with soft/hard tabs when reading vim configurations from files. But at least we've narrowed it down for you which might help @nathansobo

@iandotkelly
Copy link

@TM100 yes - I see that, the behavior of Atom only changes when I save quit and reopen the file. This behavior implies that it is still the comment block that is causing the problem. I've got used to using such blocks, but if it would fix my issue I would change.

@probablycorey
Copy link

@iandotkelly I found the problem! The isComment method on Tokenized line https://github.com/atom/atom/blob/0ad26c337a35cccf7f645ae05e71aab5841f9fbc/src/tokenized-line.coffee#L143 isn't returning the correct value for javascript block comments.

Since this is an Atom core bug I've closed this issue and moved it to atom/atom#2421

@iandotkelly
Copy link

@probablycorey - Hey that's great news. Thanks!

@chamons
Copy link
Author

chamons commented Jun 4, 2014

@probablycorey This didn't fix me (see http://discuss.atom.io/t/sometimes-tab-inserts-spaces-even-with-soft-tabs-off/3976/21).

Should I open a new issue?

@probablycorey
Copy link

@chamons are you looking for a config option that turns off automatic tab style detection?

I think this might be a valid config option, but I'd like to know more about the problems the automatic detection is causing. Could you create a gist or point me to a sample file that exhibits the behavior you want fixed.

@thomassross
Copy link

This is a very bad thing when editing Makefiles.

@nathansobo nathansobo reopened this Jun 24, 2014
@nathansobo
Copy link
Contributor

@Th0masR0ss can you send me an example of the Makefile where the tab setting is incorrectly detected?

@chamons
Copy link
Author

chamons commented Jun 24, 2014

I'm having trouble making the issue reproduce outside my project. I can take a file where detection is incorrect, copy paste and save it somewhere else with the same name, open that file up and tab "works", while it is still broken locally.

I'd love an option to just force tab to output actual tab characters and stop guessing.

@iandotkelly
Copy link

@chamons - I hear you. I get atom into all sort of strange states switching between projects that use tabs, and projects that use spaces. I would like to be able to force it rather than it guessing.

@thomassross
Copy link

@nathansobo Sorry, the problem was I was still using 0.95. I've updated, and it works now, however there was one case where Atom used soft tabs even though I told it not to but I can't reproduce it anymore.

@thomassross
Copy link

I second third @chamons's idea to have a "force hard tabs" option

@thomassross
Copy link

This issue should be moved to atom/atom now anyway because usesSoftTabs is in the Editor class.

@probablycorey
Copy link

You can toggle soft-tab on/off on an individual editor using the editor:toggle-soft. But this setting won't persist after the editor is closed. This issue is obviously annoying for some people, so someone could open this issue on the atom repo with a description of how they expect it to behave that would be great!

@KevinMcCoy
Copy link

Problem still here why is this close?

I'm trying to find and replace all space to tabs, and right after I replace all, atom change it right back to space....

@bananavoid
Copy link

Same problem as @KevinMcCoy wrote

@rinux55
Copy link

rinux55 commented Dec 1, 2015

I also still have the problem. This makes Atom not usable for me.

@James-Firth
Copy link

This has also been causing a lot of issues with the team I'm on. I'm likely to switch back to Sublime now.

@MattWilcox
Copy link

Why is this marked as closed? This error persists.

@thomassross
Copy link

Hey guys,

A quick & easy fix is to install auto-detect-indentation

@benogle
Copy link
Contributor

benogle commented Jan 25, 2016

You folks can set these settings:

screen shot 2016-01-25 at 2 50 04 pm

core.tabType in config.cson

and

screen shot 2016-01-25 at 2 50 11 pm

core.softTabs in config.cson

You can scope them to languages

The auto-detection result will persist after manually replacing all tabs with another tab type. So if you replace them all, reload the file or set the tabType setting to the type you want.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests