Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Indenter doesn't produce proper indentation #3943

Closed
IvenBach opened this issue Apr 18, 2018 · 1 comment
Closed

Indenter doesn't produce proper indentation #3943

IvenBach opened this issue Apr 18, 2018 · 1 comment
Assignees
Labels
bug Identifies work items for known bugs edge-case Marks a bug as an edge case that would be nice to fix, but that likely doesn't affect normal use. feature-smart-indenter

Comments

@IvenBach
Copy link
Member

While reviewing the tweeted article https://twitter.com/rubberduckvba/status/986058407013646336 I pasted the code in the indenter and didn't get correct indentation.

Pre-indent

Sub findbordr()
Dim r As Long
r = 1

Dim c As Long
c = 1
Do Until r > 46
If Cells(r, c).Interior.ColorIndex <> xlNone Then

    If Cells(r, c).Offset(0, 1).Interior.ColorIndex = xlNone Then
    Cells(r, c).Borders(xlEdgeRight).LineStyle = xlContinuous
    End If
    
    If c = 1 Then
    Cells(r, c).Borders(xlEdgeLeft).LineStyle = xlContinuous
    c = c + 1
    End If
    
    If Cells(r, c).Offset(0, -1).Interior.ColorIndex = xlNone Then
        Cells(r, c).Borders(xlEdgeLeft).LineStyle = xlContinuous

        c = c + 1
    Else:
        c = c + 1
    If c > 52 Then
        c = 1
        r = r + 1
    End If
    End If
        Else:
        c = c + 1
        If c > 52 Then
            r = r + 1
            c = 1
        End If
    End If
    Loop
Call findbordt
End Sub

Sub findbordt()
Dim r As Long
r = 2

Dim c As Long
c = 2
Do Until r > 46
If Cells(r, c).Interior.ColorIndex <> xlNone Then
    If Cells(r, c).Offset(1, 0).Interior.ColorIndex = xlNone Then
    Cells(r, c).Borders(xlEdgeBottom).LineStyle = xlContinuous
    End If

    If Cells(r, c).Offset(-1, 0).Interior.ColorIndex = xlNone Then
    Cells(r, c).Borders(xlEdgeTop).LineStyle = xlContinuous
    c = c + 1
    Else:
    c = c + 1
    If c > 52 Then
        c = 1
        r = r + 1
        End If
        End If
        Else:
        c = c + 1
        If c > 52 Then
        r = r + 1
        c = 1
        End If
        End If
    Loop
End Sub

Post-Indent

Sub findbordr()
    Dim r As Long
    r = 1

    Dim c As Long
    c = 1
    Do Until r > 46
        If Cells(r, c).Interior.ColorIndex <> xlNone Then

            If Cells(r, c).Offset(0, 1).Interior.ColorIndex = xlNone Then
                Cells(r, c).Borders(xlEdgeRight).LineStyle = xlContinuous
            End If
    
            If c = 1 Then
                Cells(r, c).Borders(xlEdgeLeft).LineStyle = xlContinuous
                c = c + 1
            End If
    
            If Cells(r, c).Offset(0, -1).Interior.ColorIndex = xlNone Then
                Cells(r, c).Borders(xlEdgeLeft).LineStyle = xlContinuous

                c = c + 1
            Else:
            c = c + 1
            If c > 52 Then
                c = 1
                r = r + 1
            End If
        End If
    Else:
    c = c + 1
    If c > 52 Then
        r = r + 1
        c = 1
    End If
End If
Loop
Call findbordt
End Sub

Sub findbordt()
    Dim r As Long
    r = 2

    Dim c As Long
    c = 2
    Do Until r > 46
        If Cells(r, c).Interior.ColorIndex <> xlNone Then
            If Cells(r, c).Offset(1, 0).Interior.ColorIndex = xlNone Then
                Cells(r, c).Borders(xlEdgeBottom).LineStyle = xlContinuous
            End If

            If Cells(r, c).Offset(-1, 0).Interior.ColorIndex = xlNone Then
                Cells(r, c).Borders(xlEdgeTop).LineStyle = xlContinuous
                c = c + 1
            Else:
            c = c + 1
            If c > 52 Then
                c = 1
                r = r + 1
            End If
        End If
    Else:
    c = c + 1
    If c > 52 Then
        r = r + 1
        c = 1
    End If
End If
Loop
End Sub

It took me a moment to catch the issue lies with Else:. I think the : causes it to be perceived as a line label but it compiles and does run. Removing : produces correct indentation.

@IvenBach IvenBach added the bug Identifies work items for known bugs label Apr 18, 2018
@IvenBach IvenBach added edge-case Marks a bug as an edge case that would be nice to fix, but that likely doesn't affect normal use. feature-smart-indenter and removed feature-smart-indenter labels Apr 18, 2018
@comintern comintern self-assigned this Jul 11, 2018
@comintern
Copy link
Contributor

This should be a fairly easy fix. Do we know of any other keywords that are valid with a colon after them?

Semi-automatic bug tracker automation moved this from ToDo to Done Aug 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Identifies work items for known bugs edge-case Marks a bug as an edge case that would be nice to fix, but that likely doesn't affect normal use. feature-smart-indenter
Projects
Development

No branches or pull requests

3 participants