(self, line)
return (line, indented_region)
Return tuple:
            line
                Region which shall NOT be erased, can be equal to argument line or less if folding
                was called on indented file item or indented collapsed directory
            indented_region
                Region which shall be erased
Return tuple:
            line
                Region which shall NOT be erased, can be equal to argument line or less if folding
                was called on indented file item or indented collapsed directory
            indented_region
                Region which shall be erased
Return tuple : line Region which shall NOT be erased can be equal to argument line or less if folding was called on indented file item or indented collapsed directory indented_region Region which shall be erased
def get_indented_region(self, line):
        '''Return tuple:
            line
                Region which shall NOT be erased, can be equal to argument line or less if folding
                was called on indented file item or indented collapsed directory
            indented_region
                Region which shall be erased
        '''
        v = self.view
        eol = line.b - 1
        if 'error' in v.scope_name(eol):  # remove inline error, e.g. <empty>
            indented_region = v.extract_scope(eol)
            return (line, indented_region)

        current_region = v.indented_region(line.b)
        next_region    = v.indented_region(line.b + 2)

        is_dir     = 'directory' in v.scope_name(line.a)
        next_empty = next_region.empty()
        this_empty = current_region.empty()
        line_in_next = next_region.contains(line)
        this_in_next = next_region.contains(current_region)

        def __should_exit():
            collapsed_dir = self.update and (line_in_next or next_empty or this_in_next)
            item_in_root  = (not is_dir or next_empty) and this_empty
            return collapsed_dir or item_in_root

        if __should_exit():
            return (None, None)

        elif self.update or (is_dir and not next_empty and not line_in_next):
            indented_region = next_region

        elif not this_empty:
            indented_region = current_region
            line = v.line(indented_region.a - 2)

        else:
            return (None, None)

        return (line, indented_region)
def get_indented_region ( self , line ) : v = self . view eol = line . b - 1 if 'error' in v . scope_name ( eol ) : # remove inline error, e.g. <empty> indented_region = v . extract_scope ( eol ) return ( line , indented_region ) current_region = v . indented_region ( line . b ) next_region = v . indented_region ( line . b + 2 ) is_dir = 'directory' in v . scope_name ( line . a ) next_empty = next_region . empty ( ) this_empty = current_region . empty ( ) line_in_next = next_region . contains ( line ) this_in_next = next_region . contains ( current_region ) def __should_exit ( ) : collapsed_dir = self . update and ( line_in_next or next_empty or this_in_next ) item_in_root = ( not is_dir or next_empty ) and this_empty return collapsed_dir or item_in_root if __should_exit ( ) : return ( None , None ) elif self . update or ( is_dir and not next_empty and not line_in_next ) : indented_region = next_region elif not this_empty : indented_region = current_region line = v . line ( indented_region . a - 2 ) else : return ( None , None ) return ( line , indented_region )