Hi,
I have noticed a weird behavior with indentation that I'm pretty sure hasn't always been present (as it would have driven me nuts). I've only seen this with python files, and since I keep my own python3 bundle I removed that and installed the default python bundle with the same results.
Let me try to illustrate.
Using the settings increaseIndentPattern = '^\s*(class|((async\s+)?(def|with|for))|elif|else|except|finally|if|try|while)\b.*:\s*$|({|[)\s*$'; decreaseIndentPattern = '^\s*(elif|else|except|finally)\b.*:|^\s*(}|])'; disableIndentCorrections = :true; indentOnPaste = 'simple';
I see the following behaviour (annotations where strange things happen):
if 1: pass else: # Expected this line to decrease indent when typing ':' (not OK) pass
def foo(): def bar(): pass return bar # I back up caret one level and type return (OK)
If I change disableIndentCorrections to :false, I get the following behaviour:
if 1: pass else: # Did decrease indent when typing ':' (OK) pass
def foo(): # back up caret to col 0 and type def => auto-indent to align with previous non-empty line (not OK) pass
# <- Force alignment to col 0, and retry def foo(): def bar(): pass return bar # I back up caret one level and type return => auto-indent to align with previous non-empty line (not OK)
FWIW, I scoured the installed bundles for any setting that might interfere, but did not find anything suspicious.
Is anyone else seeing the same behaviour, and if so, has it always been that way? Is there something I can do to fix it?
Regards, Per
On 25 Aug 2020, at 14:34, Per Persson via TextMate wrote:
Hi,
I have noticed a weird behavior with indentation that I'm pretty sure hasn't always been present (as it would have driven me nuts). I've only seen this with python files, and since I keep my own python3 bundle I removed that and installed the default python bundle with the same results.
Let me try to illustrate.
Using the settings increaseIndentPattern = '^\s*(class|((async\s+)?(def|with|for))|elif|else|except|finally|if|try|while)\b.*:\s*$|({|[)\s*$'; decreaseIndentPattern = '^\s*(elif|else|except|finally)\b.*:|^\s*(}|])'; disableIndentCorrections = :true; indentOnPaste = 'simple';
I forget the details of the behavior I didn’t like before, but I use
disableIndentCorrections = 'emptyLines'
Give that a try. Python is my primary language and it mostly does what I want. The exceptions:
It doesn’t auto-indent after `(`, but that’s probably the language grammar.
After a block like
~~~python class MyClass: def action(self): pass
⇥ ~~~
Hitting ⇥ at the location shown above will line up with `pass` and not the previous `def`. I guess it’s doing the thing that makes sense, even though it’s never what I want and bites me almost daily.