- Is the setTimeout actually needed? I would have thought you could call detectIndentation directly from onLoad.
- You probably meant min() below, rather than max().
sample = view.substr(sublime.Region(0, max(view.size(), 25000)))
- You can pass bools and ints to options.set(), i.e.,
Also, instead of:
for indent in sorted(spacesList):
I think you'll get better results by doing:
for indent in xrange(8, 1, -1):
because you want to test from largest to smallest (otherwise a single 2 space indentation in an otherwise 4 space indented file will yield a tabSize of 2), and you only need to test each indentation level once, so you may as well just iterate over the small set of possibilities.
Finally, before setting translateTabsToSpaces to false, it's probably worth checking that there are at least a handful of tabs in the file, otherwise opening an empty file will automatically clobber your default translateTabsToSpaces setting.
I'm looking forward to including this in the default distribution