File tree Expand file tree Collapse file tree 2 files changed +11
-5
lines changed
Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -164,9 +164,12 @@ export class CellToolbarTracker implements IDisposable {
164164 const newDefaultTags =
165165 ( this . _settings . composite [ 'defaultTags' ] as string [ ] ) || [ ] ;
166166 // Update default tag in shared tag list
167- this . _allTags . pushAll (
168- newDefaultTags . filter ( tag => ! this . _previousDefaultTags . includes ( tag ) )
167+ const toAdd = newDefaultTags . filter (
168+ tag => ! this . _previousDefaultTags . includes ( tag )
169169 ) ;
170+ if ( toAdd . length > 0 ) {
171+ this . _allTags . pushAll ( toAdd ) ;
172+ }
170173 this . _previousDefaultTags
171174 . filter ( tag => ! newDefaultTags . includes ( tag ) )
172175 . forEach ( tag => this . _allTags . removeValue ( tag ) ) ;
Original file line number Diff line number Diff line change @@ -31,7 +31,9 @@ export class TagTool extends Widget {
3131
3232 // Update tag list
3333 const tags : string [ ] = ( model . metadata . get ( 'tags' ) as string [ ] ) || [ ] ;
34- allTags . pushAll ( tags ) ; // We don't care about duplicate here so we can remove all occurrences at will
34+ if ( tags . length > 0 ) {
35+ allTags . pushAll ( tags ) ; // We don't care about duplicate here so we can remove all occurrences at will
36+ }
3537 model . metadata . changed . connect ( this . onCellMetadataChanged , this ) ;
3638 }
3739
@@ -99,17 +101,18 @@ export class TagTool extends Widget {
99101 refreshTags ( ) : void {
100102 const layout = this . layout as PanelLayout ;
101103 const tags : string [ ] = [ ...new Set ( toArray ( this . _tagList ) ) ] ;
102-
104+ const toDispose = new Array < Widget > ( ) ;
103105 layout . widgets . forEach ( widget => {
104106 if ( widget . id !== 'add-tag' ) {
105107 const idx = tags . indexOf ( ( widget as TagWidget ) . name ) ;
106108 if ( idx < 0 ) {
107- widget . dispose ( ) ;
109+ toDispose . push ( widget ) ;
108110 } else {
109111 tags . splice ( idx , 1 ) ;
110112 }
111113 }
112114 } ) ;
115+ toDispose . forEach ( widget => widget . dispose ( ) ) ;
113116
114117 tags . forEach ( tag => {
115118 layout . insertWidget (
You can’t perform that action at this time.
0 commit comments