rubberduck-vba / Rubberduck

Every programmer needs a rubberduck. COM add-in for the VBA & VB6 IDE (VBE).
https://rubberduckvba.com
GNU General Public License v3.0
1.91k stars 300 forks source link

Indent works on Current Module, but not on Current Project #5423

Open rgbigel opened 4 years ago

rgbigel commented 4 years ago

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.0.5381

Description Nothing happens when Indent Current Project is selected. Ctrl-M works on Module level

Vogel612 commented 4 years ago

found in the logs attached at the related issue #5424:

2020-03-04 13:50:58.5182;ERROR-2.5.0.5367;Rubberduck.UI.CodeExplorer.Commands.IndentCommand;System.ArgumentOutOfRangeException: Index and length must refer to a location within the string.
Parameter name: length
   at System.String.Substring(Int32 startIndex, Int32 length)
   at Rubberduck.SmartIndenter.LogicalCodeLine.FunctionAlign(String line, Boolean splitNamed) in C:\projects\rubberduck\Rubberduck.SmartIndenter\LogicalCodeLine.cs:line 257
   at Rubberduck.SmartIndenter.LogicalCodeLine.Indented() in C:\projects\rubberduck\Rubberduck.SmartIndenter\LogicalCodeLine.cs:line 133
   at Rubberduck.SmartIndenter.Indenter.GenerateCodeLineStrings(IEnumerable`1 logical, Boolean forceTrailingNewLines, Boolean procedure) in C:\projects\rubberduck\Rubberduck.SmartIndenter\Indenter.cs:line 359
   at Rubberduck.SmartIndenter.Indenter.Indent(IEnumerable`1 codeLines, Boolean forceTrailingNewLines, Boolean procedure) in C:\projects\rubberduck\Rubberduck.SmartIndenter\Indenter.cs:line 299
   at Rubberduck.SmartIndenter.Indenter.Indent(IVBComponent component) in C:\projects\rubberduck\Rubberduck.SmartIndenter\Indenter.cs:line 154
   at Rubberduck.UI.CodeExplorer.Commands.IndentCommand.OnExecute(Object parameter) in C:\projects\rubberduck\Rubberduck.Core\UI\CodeExplorer\Commands\IndentCommand.cs:line 107
   at Rubberduck.UI.Command.CommandBase.Execute(Object parameter) in C:\projects\rubberduck\Rubberduck.Core\UI\Command\CommandBase.cs:line 85;System.ArgumentOutOfRangeException: Index and length must refer to a location within the string.
Parameter name: length
   at System.String.Substring(Int32 startIndex, Int32 length)
   at Rubberduck.SmartIndenter.LogicalCodeLine.FunctionAlign(String line, Boolean splitNamed) in C:\projects\rubberduck\Rubberduck.SmartIndenter\LogicalCodeLine.cs:line 257
   at Rubberduck.SmartIndenter.LogicalCodeLine.Indented() in C:\projects\rubberduck\Rubberduck.SmartIndenter\LogicalCodeLine.cs:line 133
   at Rubberduck.SmartIndenter.Indenter.GenerateCodeLineStrings(IEnumerable`1 logical, Boolean forceTrailingNewLines, Boolean procedure) in C:\projects\rubberduck\Rubberduck.SmartIndenter\Indenter.cs:line 359
   at Rubberduck.SmartIndenter.Indenter.Indent(IEnumerable`1 codeLines, Boolean forceTrailingNewLines, Boolean procedure) in C:\projects\rubberduck\Rubberduck.SmartIndenter\Indenter.cs:line 299
   at Rubberduck.SmartIndenter.Indenter.Indent(IVBComponent component) in C:\projects\rubberduck\Rubberduck.SmartIndenter\Indenter.cs:line 154
   at Rubberduck.UI.CodeExplorer.Commands.IndentCommand.OnExecute(Object parameter) in C:\projects\rubberduck\Rubberduck.Core\UI\CodeExplorer\Commands\IndentCommand.cs:line 107
   at Rubberduck.UI.Command.CommandBase.Execute(Object parameter) in C:\projects\rubberduck\Rubberduck.Core\UI\Command\CommandBase.cs:line 85

Seems like there is indeed a bug in the indenter that breaks the command execution

MikeAndLisa commented 4 years ago

I think there is a workaround. Untick/Disable the Keys Ctrl M and the other items can be selected in the indent menu options.