@@ -133,53 +133,99 @@ void InitializeTheme()
133133
134134 void RefreshTree ( )
135135 {
136+ var search = input . Text . Trim ( ) ;
137+ TypeNode selectedNode = null ;
138+ if ( search . Length > 1 && search . Contains ( '.' ) && tree . Nodes . Count > 0 )
139+ {
140+ var node = SelectedNode as TypeNode ?? ( TypeNode ) tree . Nodes [ 0 ] ;
141+ var parts = search . Split ( '.' ) ;
142+ if ( node . Name == parts [ 0 ] )
143+ {
144+ selectedNode = node ;
145+ search = parts [ 1 ] ;
146+ }
147+ }
136148 tree . BeginUpdate ( ) ;
137149 tree . Nodes . Clear ( ) ;
138- FillTree ( ) ;
150+ if ( selectedNode == null )
151+ {
152+ if ( search . Length == 0 ) FillTree ( ) ;
153+ else FillTree ( search ) ;
154+ if ( tree . Nodes . Count > 0 ) tree . SelectedNode = tree . Nodes [ 0 ] ;
155+ }
156+ else
157+ {
158+ selectedNode . Nodes . Clear ( ) ;
159+ tree . Nodes . Add ( selectedNode ) ;
160+ FillTree ( selectedNode , search ) ;
161+ tree . SelectedNode = selectedNode . FirstNode ?? selectedNode ;
162+ }
139163 tree . ExpandAll ( ) ;
140164 tree . EndUpdate ( ) ;
141165 }
142166
143167 void FillTree ( )
144168 {
145- var search = input . Text . Trim ( ) ;
146- var openedTypes = this . openedTypes . ToList ( ) ;
147- var closedTypes = this . closedTypes . ToList ( ) ;
148- if ( CurrentFilter != null )
169+ var openedTypes = FilterTypes ( this . openedTypes . ToList ( ) ) ;
170+ if ( openedTypes . Count > 0 ) tree . Nodes . AddRange ( CreateNodes ( openedTypes , string . Empty ) . ToArray ( ) ) ;
171+ }
172+
173+ void FillTree ( string search )
174+ {
175+ var openedTypes = FilterTypes ( this . openedTypes . ToList ( ) ) ;
176+ var closedTypes = FilterTypes ( this . closedTypes . ToList ( ) ) ;
177+ var maxItems = Settings . MaxItems ;
178+ var openedMatches = openedTypes . Count > 0 ? SearchUtil . FindAll ( openedTypes , search ) : new List < string > ( ) ;
179+ var closedMatches = new List < string > ( ) ;
180+ if ( maxItems > 0 )
149181 {
150- var flags = ( FlagType ) CurrentFilter . Tag ;
151- openedTypes . RemoveAll ( it => ( TypeToClassModel [ it ] . Flags & flags ) == 0 ) ;
152- closedTypes . RemoveAll ( it => ( TypeToClassModel [ it ] . Flags & flags ) == 0 ) ;
182+ if ( openedMatches . Count >= maxItems ) openedMatches = openedMatches . GetRange ( 0 , maxItems ) ;
183+ maxItems -= openedMatches . Count ;
184+ if ( maxItems > 0 )
185+ {
186+ closedMatches = SearchUtil . FindAll ( closedTypes , search ) ;
187+ if ( closedMatches . Count >= maxItems ) closedMatches = closedMatches . GetRange ( 0 , maxItems ) ;
188+ }
153189 }
154- var openedCount = openedTypes . Count ;
155- if ( search . Length == 0 )
190+ else closedMatches = SearchUtil . FindAll ( closedTypes , search ) ;
191+ var hasOpenedMatches = openedMatches . Count > 0 ;
192+ var hasClosedMatches = closedMatches . Count > 0 ;
193+ if ( hasOpenedMatches ) tree . Nodes . AddRange ( CreateNodes ( openedMatches , search ) . ToArray ( ) ) ;
194+ if ( Settings . EnableItemSpacer && hasOpenedMatches && hasClosedMatches )
195+ tree . Nodes . Add ( Settings . ItemSpacer ) ;
196+ if ( hasClosedMatches ) tree . Nodes . AddRange ( CreateNodes ( closedMatches , search ) . ToArray ( ) ) ;
197+ }
198+
199+ void FillTree ( TypeNode node , string search )
200+ {
201+ var nodes = node . Nodes ;
202+ var currentClass = node . Model ;
203+ var inFile = currentClass . InFile ;
204+ var isHaxe = inFile . haXe ;
205+ var items = currentClass . Members . Items . ToList ( ) ;
206+ if ( search . Length > 0 ) items = SearchUtil . FindAll ( items , search ) ;
207+ foreach ( var it in items )
156208 {
157- if ( openedCount > 0 ) tree . Nodes . AddRange ( CreateNodes ( openedTypes , string . Empty ) . ToArray ( ) ) ;
209+ var flags = it . Flags ;
210+ var icon = PluginUI . GetIcon ( flags , it . Access ) ;
211+ var constrDecl = isHaxe && ( flags & FlagType . Constructor ) > 0 ? "new" : it . FullName ;
212+ nodes . Add ( new MemberNode ( it . ToString ( ) , icon , icon )
213+ {
214+ Tag = $ "{ constrDecl } @{ it . LineFrom } ",
215+ InFile = inFile
216+ } ) ;
158217 }
159- else
218+ }
219+
220+ [ NotNull ]
221+ List < string > FilterTypes ( List < string > list )
222+ {
223+ if ( CurrentFilter != null )
160224 {
161- var maxItems = Settings . MaxItems ;
162- var openedMatches = openedCount > 0 ? SearchUtil . FindAll ( openedTypes , search ) : new List < string > ( ) ;
163- var closedMatches = new List < string > ( ) ;
164- if ( maxItems > 0 )
165- {
166- if ( openedMatches . Count >= maxItems ) openedMatches = openedMatches . GetRange ( 0 , maxItems ) ;
167- maxItems -= openedMatches . Count ;
168- if ( maxItems > 0 )
169- {
170- closedMatches = SearchUtil . FindAll ( closedTypes , search ) ;
171- if ( closedMatches . Count >= maxItems ) closedMatches = closedMatches . GetRange ( 0 , maxItems ) ;
172- }
173- }
174- else closedMatches = SearchUtil . FindAll ( closedTypes , search ) ;
175- var hasOpenedMatches = openedMatches . Count > 0 ;
176- var hasClosedMatches = closedMatches . Count > 0 ;
177- if ( hasOpenedMatches ) tree . Nodes . AddRange ( CreateNodes ( openedMatches , search ) . ToArray ( ) ) ;
178- if ( Settings . EnableItemSpacer && hasOpenedMatches && hasClosedMatches )
179- tree . Nodes . Add ( Settings . ItemSpacer ) ;
180- if ( hasClosedMatches ) tree . Nodes . AddRange ( CreateNodes ( closedMatches , search ) . ToArray ( ) ) ;
225+ var flags = ( FlagType ) CurrentFilter . Tag ;
226+ list . RemoveAll ( it => ( TypeToClassModel [ it ] . Flags & flags ) == 0 ) ;
181227 }
182- if ( tree . Nodes . Count > 0 ) tree . SelectedNode = tree . Nodes [ 0 ] ;
228+ return list ;
183229 }
184230
185231 [ NotNull ]
@@ -412,6 +458,13 @@ void OnInputKeyDown(object sender, KeyEventArgs e)
412458 {
413459 if ( tree . Nodes . Count == 0 ) return ;
414460 var keyCode = e . KeyCode ;
461+ if ( e . Control && keyCode == Keys . Right && SelectedNode is TypeNode )
462+ {
463+ e . Handled = true ;
464+ input . Text = ( ( TypeNode ) SelectedNode ) . Model . Name ;
465+ input . SelectionStart = input . TextLength ;
466+ return ;
467+ }
415468 if ( keysToFilter . ContainsKey ( keyCode ) )
416469 {
417470 e . Handled = e . Alt ;
0 commit comments