File tree Expand file tree Collapse file tree 3 files changed +18
-12
lines changed
test/browser/parts/editor Expand file tree Collapse file tree 3 files changed +18
-12
lines changed Original file line number Diff line number Diff line change @@ -665,15 +665,25 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
665
665
this . disposedEditorsWorker . work ( editor ) ;
666
666
}
667
667
668
- private handleDisposedEditors ( editors : EditorInput [ ] ) : void {
668
+ private handleDisposedEditors ( disposedEditors : EditorInput [ ] ) : void {
669
669
670
670
// Split between visible and hidden editors
671
671
let activeEditor : EditorInput | undefined ;
672
672
const inactiveEditors : EditorInput [ ] = [ ] ;
673
- for ( const editor of editors ) {
673
+ for ( const disposedEditor of disposedEditors ) {
674
+ const editorFindResult = this . model . findEditor ( disposedEditor ) ;
675
+ if ( ! editorFindResult ) {
676
+ continue ; // not part of the model anymore
677
+ }
678
+
679
+ const editor = editorFindResult [ 0 ] ;
680
+ if ( ! editor . isDisposed ( ) ) {
681
+ continue ; // editor got reopened meanwhile
682
+ }
683
+
674
684
if ( this . model . isActive ( editor ) ) {
675
685
activeEditor = editor ;
676
- } else if ( this . model . contains ( editor ) ) {
686
+ } else {
677
687
inactiveEditors . push ( editor ) ;
678
688
}
679
689
}
Original file line number Diff line number Diff line change @@ -869,7 +869,7 @@ export class EditorGroupModel extends Disposable {
869
869
}
870
870
}
871
871
872
- indexOf ( candidate : EditorInput | null , editors = this . editors , options ?: IMatchEditorOptions ) : number {
872
+ indexOf ( candidate : EditorInput | IUntypedEditorInput | null , editors = this . editors , options ?: IMatchEditorOptions ) : number {
873
873
let index = - 1 ;
874
874
if ( ! candidate ) {
875
875
return index ;
@@ -894,7 +894,7 @@ export class EditorGroupModel extends Disposable {
894
894
return index ;
895
895
}
896
896
897
- private findEditor ( candidate : EditorInput | null , options ?: IMatchEditorOptions ) : [ EditorInput , number /* index */ ] | undefined {
897
+ findEditor ( candidate : EditorInput | null , options ?: IMatchEditorOptions ) : [ EditorInput , number /* index */ ] | undefined {
898
898
const index = this . indexOf ( candidate , this . editors , options ) ;
899
899
if ( index === - 1 ) {
900
900
return undefined ;
@@ -912,13 +912,7 @@ export class EditorGroupModel extends Disposable {
912
912
}
913
913
914
914
contains ( candidate : EditorInput | IUntypedEditorInput , options ?: IMatchEditorOptions ) : boolean {
915
- for ( const editor of this . editors ) {
916
- if ( this . matches ( editor , candidate , options ) ) {
917
- return true ;
918
- }
919
- }
920
-
921
- return false ;
915
+ return this . indexOf ( candidate , this . editors , options ) !== - 1 ;
922
916
}
923
917
924
918
private matches ( editor : EditorInput | null , candidate : EditorInput | IUntypedEditorInput | null , options ?: IMatchEditorOptions ) : boolean {
Original file line number Diff line number Diff line change @@ -814,6 +814,7 @@ suite('EditorGroupModel', () => {
814
814
815
815
assert . strictEqual ( group . count , 1 ) ;
816
816
assert . strictEqual ( group . getEditors ( EditorsOrder . MOST_RECENTLY_ACTIVE ) . length , 1 ) ;
817
+ assert . strictEqual ( group . findEditor ( input1 ) ! [ 0 ] , input1 ) ;
817
818
assert . strictEqual ( group . activeEditor , input1 ) ;
818
819
assert . strictEqual ( group . isActive ( input1 ) , true ) ;
819
820
assert . strictEqual ( group . isPinned ( input1 ) , true ) ;
@@ -827,6 +828,7 @@ suite('EditorGroupModel', () => {
827
828
assert . strictEqual ( events . activated [ 0 ] . editorIndex , 0 ) ;
828
829
829
830
const index = group . indexOf ( input1 ) ;
831
+ assert . strictEqual ( group . findEditor ( input1 ) ! [ 1 ] , index ) ;
830
832
let event = group . closeEditor ( input1 , EditorCloseContext . UNPIN ) ;
831
833
assert . strictEqual ( event ?. editor , input1 ) ;
832
834
assert . strictEqual ( event ?. editorIndex , index ) ;
You can’t perform that action at this time.
0 commit comments