Home Download Buy Blog Forum Support

Weird tab behaviour in beta 20100613

Weird tab behaviour in beta 20100613

Postby asmodai on Thu Aug 12, 2010 8:43 am

So I was working on Python files and no matter how often I reloaded this Python file it kept setting tab width to 8 characters, despite my Python configuration file having:

Code: Select all
tabSize 4
translateTabsToSpaces true


One weird thing was that it explicitly said at the bottom of the editor that it was setting tab width to 8.

I had the same happening with HTML where it did not follow my tabSize 2.

Anyone else had strange tab behaviour like this? It kept repeating despite closing and starting Sublime Text a few times. And now a day later it seems to behave again. :shock:
asmodai
 
Posts: 73
Joined: Mon Mar 01, 2010 10:42 am

Re: Weird tab behaviour in beta 20100613

Postby jps on Thu Aug 12, 2010 11:07 am

This behaviour is controlled by the detectIndentation setting: it tries to automatically determine the indentation settings of the file on load.

You can disable this by setting:

Code: Select all
detectIndentation false
jps
Site Admin
 
Posts: 3067
Joined: Wed Mar 19, 2008 12:33 pm

Re: Weird tab behaviour in beta 20100613

Postby asmodai on Sun Aug 15, 2010 12:17 pm

I have to say that detectIndentation is a bit flawed though. Why would it set tabs to 8 spaces when the whole Python file I am editing uses 4 space indents?
asmodai
 
Posts: 73
Joined: Mon Mar 01, 2010 10:42 am

Re: Weird tab behaviour in beta 20100613

Postby jps on Sun Aug 15, 2010 12:40 pm

It generally works quite well. In this case, it'll be choosing an 8 space indent because 80% of the lines are indented with a multiple of 8 spaces. Perhaps there's an argument to be made that the threshold should be greater than 80%.
jps
Site Admin
 
Posts: 3067
Joined: Wed Mar 19, 2008 12:33 pm

Re: Weird tab behaviour in beta 20100613

Postby asmodai on Sun Aug 15, 2010 5:26 pm

Aha, so it doesn't check the flow control indentation but the overall percentage of indentation present in the code. Mmm.

The problem than arises when you have small files that have to do something like this:

Code: Select all
class DoHickey(object):
    def __init__(self):
        code
        code
        code

    def method(self, arguments):
        more code
        more code
        more code

You will quickly then trip the 8 space tab width.
asmodai
 
Posts: 73
Joined: Mon Mar 01, 2010 10:42 am

Re: Weird tab behaviour in beta 20100613

Postby rbabiak on Wed Aug 25, 2010 8:06 am

jps wrote:It generally works quite well. In this case, it'll be choosing an 8 space indent because 80% of the lines are indented with a multiple of 8 spaces. Perhaps there's an argument to be made that the threshold should be greater than 80%.


so with python we are useing 4 spaces for each indentation, but most python is two+ indentations levels.

i guess it could get confused with multiples of your desired indentation.
rbabiak
 
Posts: 37
Joined: Sun Oct 25, 2009 12:33 pm

Re: Weird tab behaviour in beta 20100613

Postby oats on Tue Jan 25, 2011 10:13 pm

It seems I'm still getting this problem with the latest beta. (Coding in Matlab, I don't know if that makes a difference.) I also have several files where most lines are indented two levels, which trips the 80% rule, and the double indentations are interpreted as one. Maybe some special case considerations would be good, such as if >80% of the lines are indented at 2X the default indentation (or 4X, 6X, etc), and the remaining lines are >50% at 1X, 3X, 5X, etc of the default, then stick with the default!
oats
 
Posts: 101
Joined: Mon Nov 09, 2009 4:39 pm


Return to Technical Support

Who is online

Users browsing this forum: Exabot [Bot], Google [Bot], Yahoo [Bot] and 23 guests