@@ -160,9 +160,9 @@ export class VscodeTree extends VscElement {
160160 prevFocusedItem : null ,
161161 hasBranchItem : false ,
162162 rootElement : this ,
163- highlightedItems : [ ] ,
164- highlightGuides : ( ) => {
165- this . _highlightGuides ( ) ;
163+ highlightedItems : new Set ( ) ,
164+ highlightIndentGuides : ( ) => {
165+ this . _highlightIndentGuides ( ) ;
166166 } ,
167167 emitSelectEvent : ( ) => {
168168 this . _emitSelectEvent ( ) ;
@@ -258,43 +258,33 @@ export class VscodeTree extends VscElement {
258258 this . dispatchEvent ( ev ) ;
259259 }
260260
261- private _highlightGuides ( ) {
262- const { activeItem, highlightedItems, selectedItems} =
263- this . _treeContextState ;
264-
265- highlightedItems . forEach ( ( i ) => ( i . highlightedGuides = false ) ) ;
266-
267- if ( activeItem ) {
268- this . _treeContextState . highlightedItems = [ ] ;
269-
270- if ( activeItem . branch && activeItem . open ) {
271- activeItem . highlightedGuides = true ;
272- this . _treeContextState . highlightedItems . push ( activeItem ) ;
273- } else {
274- const parent = findParentItem ( activeItem ) ;
261+ private _highlightIndentGuideOfItem ( item : VscodeTreeItem ) {
262+ if ( item . branch && item . open ) {
263+ item . highlightedGuides = true ;
264+ this . _treeContextState . highlightedItems ?. add ( item ) ;
265+ } else {
266+ const parent = findParentItem ( item ) ;
275267
276- if ( parent && parent . branch ) {
277- parent . highlightedGuides = true ;
278- this . _treeContextState . highlightedItems . push ( parent ) ;
279- }
268+ if ( parent ) {
269+ parent . highlightedGuides = true ;
270+ this . _treeContextState . highlightedItems ?. add ( parent ) ;
280271 }
281272 }
273+ }
282274
283- if ( selectedItems ) {
284- selectedItems . forEach ( ( item ) => {
285- if ( item . branch && item . open ) {
286- item . highlightedGuides = true ;
287- this . _treeContextState . highlightedItems . push ( item ) ;
288- } else {
289- const parent = findParentItem ( item ) ;
290-
291- if ( parent && parent . branch ) {
292- parent . highlightedGuides = true ;
293- this . _treeContextState . highlightedItems . push ( item ) ;
294- }
295- }
296- } ) ;
275+ private _highlightIndentGuides ( ) {
276+ this . _treeContextState . highlightedItems ?. forEach (
277+ ( i ) => ( i . highlightedGuides = false )
278+ ) ;
279+ this . _treeContextState . highlightedItems ?. clear ( ) ;
280+
281+ if ( this . _treeContextState . activeItem ) {
282+ this . _highlightIndentGuideOfItem ( this . _treeContextState . activeItem ) ;
297283 }
284+
285+ this . _treeContextState . selectedItems . forEach ( ( item ) => {
286+ this . _highlightIndentGuideOfItem ( item ) ;
287+ } ) ;
298288 }
299289
300290 private _updateConfigContext ( changedProperties : PropertyValues ) {
@@ -326,6 +316,7 @@ export class VscodeTree extends VscElement {
326316
327317 item . updateComplete . then ( ( ) => {
328318 item . focus ( ) ;
319+ this . _highlightIndentGuides ( ) ;
329320 } ) ;
330321 }
331322
@@ -430,6 +421,8 @@ export class VscodeTree extends VscElement {
430421 this . _treeContextState . selectedItems . forEach (
431422 ( li ) => ( li . selected = false )
432423 ) ;
424+ this . _treeContextState . selectedItems . clear ( ) ;
425+ this . _highlightIndentGuides ( ) ;
433426
434427 focusedItem . selected = true ;
435428 this . _emitSelectEvent ( ) ;
@@ -497,7 +490,7 @@ export class VscodeTree extends VscElement {
497490 }
498491 }
499492
500- this . _highlightGuides ( ) ;
493+ // this._highlightGuides();
501494 } ) ;
502495 } ;
503496
0 commit comments