Skip to content

Commit af1a539

Browse files
authored
Merge pull request #2090 from Hosch250/Issue2069
Fix random sort order
2 parents e4bc593 + 4385dfb commit af1a539

File tree

2 files changed

+21
-13
lines changed

2 files changed

+21
-13
lines changed

RetailCoder.VBE/Navigation/CodeExplorer/CodeExplorerItemViewModel.cs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System.Collections.Generic;
22
using System.Linq;
33
using System.Windows.Media.Imaging;
4+
using Microsoft.Vbe.Interop;
45
using Rubberduck.Parsing.Symbols;
56
using Rubberduck.UI;
67
using Rubberduck.VBEditor;
@@ -74,15 +75,22 @@ public override int Compare(CodeExplorerItemViewModel x, CodeExplorerItemViewMod
7475
return xNode.Declaration.DeclarationType < yNode.Declaration.DeclarationType ? -1 : 1;
7576
}
7677

77-
// keep types with different icons and the same declaration type (document/class module) separate
78-
// documents come first
78+
if (xNode.Declaration.Accessibility != yNode.Declaration.Accessibility)
79+
{
80+
return xNode.Declaration.Accessibility < yNode.Declaration.Accessibility ? -1 : 1;
81+
}
82+
7983
if (x.ExpandedIcon != y.ExpandedIcon)
8084
{
81-
// ReSharper disable once PossibleInvalidOperationException - this will have a component
82-
return x.QualifiedSelection.Value.QualifiedName.Component.Type ==
83-
Microsoft.Vbe.Interop.vbext_ComponentType.vbext_ct_Document
84-
? -1
85-
: 1;
85+
// ReSharper disable PossibleInvalidOperationException - this will have a component
86+
var xComponent = x.QualifiedSelection.Value.QualifiedName.Component;
87+
var yComponent = y.QualifiedSelection.Value.QualifiedName.Component;
88+
89+
if (xComponent.Type == vbext_ComponentType.vbext_ct_Document ^
90+
yComponent.Type == vbext_ComponentType.vbext_ct_Document)
91+
{
92+
return xComponent.Type == vbext_ComponentType.vbext_ct_Document ? -1 : 1;
93+
}
8694
}
8795

8896
return 0;

Rubberduck.Parsing/Symbols/Accessibility.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
{
33
public enum Accessibility
44
{
5-
Implicit,
6-
Private,
7-
Public,
8-
Global,
9-
Friend,
10-
Static,
5+
Private = 1,
6+
Friend = 2,
7+
Implicit = 3,
8+
Public = 4,
9+
Global = 5,
10+
Static = 6,
1111
}
1212
}

0 commit comments

Comments
 (0)