Author Topic: Python indent fail with adaptive formatting.  (Read 1901 times)

jporkkahtc

  • Senior Community Member
  • Posts: 2620
  • Hero Points: 210
  • Text
Python indent fail with adaptive formatting.
« on: September 11, 2017, 09:57:19 PM »
Given a foo.py file with this code:
Code: [Select]
def fn(a,b,c,d):
    for filename in d:
        if len(d) > 1:
            log("PROCESSING", filename)
        #read_file(filename)

If I insert "if blah:" before the "FOR", Slick will autoindent the rest of the code as I press down arrow.
This is really nice.

BUT, given this code:
Code: [Select]
def fn(a,b,c,d):
    for filename in d:
        if len(d) > 1:
            log("PROCESSING", filename)
        #read_file(filename)

def fn2():
    pass
and I do the same, Slick is only willing to indent the "for" and the "if", it won't go any further - so then I have to manually indent the "log" and comment lines.

Code: [Select]
def fn(a,b,c,d):
    if blah:
        for filename in d:
            if len(d) > 1:
            log("PROCESSING", filename)
        #read_file(filename)

def fn2():
    pass


patrick

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1818
  • Hero Points: 151
Re: Python indent fail with adaptive formatting.
« Reply #1 on: September 12, 2017, 02:46:02 PM »
Reproduced.  Not sure what's going on there, I'll take a look at it.

patrick

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1818
  • Hero Points: 151
Re: Python indent fail with adaptive formatting.
« Reply #2 on: September 20, 2017, 01:21:36 PM »
Fixed for the next beta drop.  You'll notice that it will also pull in the whole FOR statement the first time you hit down arrow, which is what it's supposed to do. 

I do see a related issue where in some cases surround can't pull in the last line of a python function.  The fix for that is simple enough, but won't make it in time for the next beta drop.