Open CoderRPM opened 5 months ago
Looks like the indenter gets confused on line continuations of strings on lines with double qutes and komma.
I created some tests cases
Sub Tests()
MsgBox "Fails," _
& "With ""Qutes"", and Comma" _
& vbCrLf
MsgBox "Fails," _
& "With """"many Qutes"", "", and Comma" & _
vbCrLf
MsgBox "Fails," _
& "With ""Qutes"" and, late Comma" _
& vbCrLf
' Some working cases
MsgBox "Works," _
& "With """"many Qutes"""", and Comma" _
& vbCrLf
MsgBox "Works," _
& "With ""Qutes"" and no Comma" _
& vbCrLf
MsgBox "Works," _
& "Without Quotes, and Komma" _
& vbCrLf
MsgBox "Works," _
& "Without Komma, and ""Quotes""" _
& vbCrLf
MsgBox "", "", _
"Works" _
& vbCrLf
End Sub
Thanks for the additional information and test cases! The 2.x indenter is essentially a (refactored to death / beyond recognition) port of the original Smart Indenter VB6 source code, which basically treats code as strings... which makes it limited in such edge cases. Makes me wonder how/whether the original indenter even deals with these (we've already patched quite a few holes from the original code)... Anyway the 3.x indenter is slated to become a "format code" command that is going to work off hierarchical symbol trees, which don't get confused with line continuations and escaped quotes; solving it in 2.x is probably not impossible, but working with strings makes it much harder than it should be.
Rubberduck version information
Version 2.5.9.6316 OS: Microsoft Windows NT 10.0.22631.0, x64 Host Product: Microsoft Office x64 Host Version: 16.0.17531.20152 Host Executable: EXCEL.EXE
Description Problem when using indenter at any level (Proj, Mod, or Proc) on a statement with multiple continuation lines (terminated with space-underscore " _").
In SOME, BUT NOT ALL circumstances, a continuation line will be indented MUCH farther to the right than the preceding continuation line.
When this strangeness occurs for a statement with multiple continuation lines, each subsequent continuation line steps farther and farther to the right and eventually falls off the right side of the window. Scrolling right shows they are still there. Just out of the window.
Somewhat strangely, in at least one example, the last two continuation lines reverted left to the indent level of the first continuation line. (see attached Clip).
Indenter Settings Indent alignment options: I have "Align Continuations" checked. Does not seem to matter if I check or un-check "Ignore Operators".
To Reproduce
Expected behavior I would prefer to have indenter pick an indent distance for the FIRST continuation line of a statement based on the rules selected by the currently specified Indent Options.
I would like subsequent continuation lines for the statement to generally align at that same indent distance.
Screenshots
Logfile I will generate a trace log if you think it would be useful.