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

Indentation failed on simple code #6191

Open
1504168 opened this issue Jan 5, 2024 · 2 comments
Open

Indentation failed on simple code #6191

1504168 opened this issue Jan 5, 2024 · 2 comments
Labels
bug Identifies work items for known bugs feature-smart-indenter

Comments

@1504168
Copy link

1504168 commented Jan 5, 2024

Rubberduck version information
The info below can be copy-paste-completed from the first lines of Rubberduck's log or the About box:

Version 2.5.9.6289
OS: Microsoft Windows NT 10.0.19045.0, x64
Host Product: Microsoft Office x64
Host Version: 16.0.17231.20008
Host Executable: EXCEL.EXE

Description
Indenting is failing on the below line of code.

Public Sub SubName()
    
    '@PossibleError: Type mismatch(13) if given input is not an array
    Dim X As Long
    X = X + 1
    
End Sub

It failed if I got rid of the @ from the comment as well. It successfully indent if I don't put any space after @PossibleError from the comment line.

Expected behavior
Expected indentation:

Public Sub SubName()
    
    '@PossibleError: Type mismatch(13) if given input is not an array
    Dim X As Long
    X = X + 1
    
End Sub
@1504168 1504168 added the bug Identifies work items for known bugs label Jan 5, 2024
@retailcoder
Copy link
Member

Repro'd online; removing the : colon formats the resulting code as expected - the indenter is probably getting confused with line labels... if I recall there's some regex-matching involved, in which case the fix for this is probably just a few characters in a regex pattern.
The plan for RD3 is to leverage parse trees for code formatting (we've talked about rewriting the indenter to do this, for years!), so this kind of problems pretty much solve themselves, because our parser has no problem telling a comment from a line label.

@1504168
Copy link
Author

1504168 commented Jan 7, 2024

Thank you.

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 feature-smart-indenter
Projects
None yet
Development

No branches or pull requests

2 participants