@@ -62,7 +62,7 @@ Private Const BEG_END_ELSEIF = "ElseIf"
62
62
Private Const BEG_END_CASE = "Case "
63
63
64
64
Private Const THEN_KEYWORD = "Then"
65
- Private Const LINE_CONTINUATION = "_"
65
+ Private Const LINE_CONTINUATION = " _"
66
66
67
67
Private Const INDENT = " "
68
68
@@ -199,8 +199,9 @@ Public Sub formatCode(codePane As codeModule)
199
199
Dim lineCount As Integer
200
200
lineCount = codePane.CountOfLines
201
201
202
- Dim indentLevel As Integer , nextLevel As Integer , levelChange As Integer
202
+ Dim indentLevel As Integer , nextLevel As Integer , levelChange As Integer , isPrevLineContinuated as Boolean
203
203
indentLevel = 0
204
+ isPrevLineContinuated = False
204
205
Dim lineNr As Integer
205
206
For lineNr = 1 To lineCount
206
207
Dim line As String
@@ -231,7 +232,10 @@ Public Sub formatCode(codePane As codeModule)
231
232
line = indentation(indentLevel) + line
232
233
indentLevel = nextLevel
233
234
End If
234
- Call codePane .ReplaceLine (lineNr, line)
235
+ If Not isPrevLineContinuated Then
236
+ Call codePane .ReplaceLine (lineNr, line)
237
+ EndIf
238
+ isPrevLineContinuated = isLineContinuated(line)
235
239
Next
236
240
Exit Sub
237
241
formatCodeError:
@@ -261,7 +265,7 @@ Private Function indentChange(ByVal line As String) As Integer
261
265
Set w = vbaWords
262
266
263
267
If isEqual(line, ONEWORD_END_FOR) Or _
264
- isEqual(line, ONEWORD_END_LOOP ) Then
268
+ lineStartsWith(ONEWORD_END_LOOP, line ) Then
265
269
indentChange = -1
266
270
GoTo hell
267
271
End If
@@ -321,6 +325,13 @@ Private Function isOneLineIfStatemt(line As String) As Boolean
321
325
End Function
322
326
323
327
328
+ Private Function isLineContinuated (line As String ) As Boolean
329
+ Dim trimmedLine As String
330
+ trimmedLine = TrimComments(line)
331
+ isLineContinuated = lineEndsWith(LINE_CONTINUATION, trimmedLine)
332
+ End Function
333
+
334
+
324
335
' Trims trailing comments (and whitespace before a comment) from a line of code
325
336
Private Function TrimComments (ByVal line As String ) As String
326
337
Dim c As Long
0 commit comments