@@ -69,15 +69,28 @@ def run(self, edit): |
69 | 69 | # extContext will store a list of contexts to keep track of all the start and start-ext calls |
70 | 70 | extContext = [] |
71 | 71 |
|
| 72 | + # resumeContext will store a list of contexts to keep track of all the resume calls |
| 73 | + resumeContext = [] |
| 74 | + |
72 | 75 | # Perform initial formatting based on Nest value |
73 | 76 | for lineContents in lines: |
74 | 77 | # extract Nest value from lineContents |
75 | 78 | match = re.search(r'(start-ext|start|end-ext|end|resume|reend)\s+Nest=(\d+)', lineContents) |
76 | 79 | if match: |
| 80 | + prevNestLevel = nestLevel |
77 | 81 | nestLevel = int(match.group(2)) - lowestNestValue |
78 | 82 |
|
| 83 | + # Always ensure that the next nest level is always only indented by 1 tab, and not more |
| 84 | + if (nestLevel - prevNestLevel) > 1: |
| 85 | + nestLevel = prevNestLevel + 1 |
| 86 | + |
79 | 87 | startIndex = 0 |
80 | 88 |
|
| 89 | + # If within a resume context |
| 90 | + if resumeContext: |
| 91 | + # The resume code already adds an extra tab, so don't need to indent here |
| 92 | + nestLevel -= 1 |
| 93 | + |
81 | 94 | for x in range(startIndex,nestLevel): |
82 | 95 | lineContents = '\t' + lineContents |
83 | 96 | sessionSpecificString = sessionSpecificString + lineContents + '\n' |
@@ -95,6 +108,8 @@ def run(self, edit): |
95 | 108 | extContext.append(matchExt.group(1)) |
96 | 109 | if match.group(1) == 'resume': |
97 | 110 | lastCall = 'resume' |
| 111 | + resumeExt = re.search(r'resume\s+Nest=(?:\d+)\s+\.\s+((?:\w+\.?)+)', lineContents) |
| 112 | + resumeContext.append(resumeExt.group(1)) |
98 | 113 | if match.group(1) == 'end-ext': |
99 | 114 | lastCall = 'end' |
100 | 115 | # remove the last element from extContext |
@@ -105,14 +120,16 @@ def run(self, edit): |
105 | 120 | extContext.pop() |
106 | 121 | if match.group(1) == 'reend': |
107 | 122 | lastCall = 'reend' |
| 123 | + # remove the last element from resumeContext |
| 124 | + resumeContext.pop() |
108 | 125 |
|
109 | 126 | else: |
110 | 127 | match = re.search(r'(call (int|setter|getter|private|method)|End-Function|end-get|end-set)', lineContents) |
111 | 128 | if match: |
112 | 129 | # if first 4 chars are 'call' |
113 | 130 | if match.group(1)[:4] == 'call': |
114 | 131 |
|
115 | | - if lastCall in ['start', 'resume'] or (lastCall[:4] == 'call'): |
| 132 | + if lastCall == 'start' or (lastCall[:4] == 'call'): |
116 | 133 | nestLevel += 1 |
117 | 134 |
|
118 | 135 | if match.group(1) == 'call method': |
|