@@ -38,6 +38,8 @@ export interface ITerminalStatusList {
38
38
39
39
/**
40
40
* Adds a status to the list.
41
+ * @param status The status object. Ideally a single status object that does not change will be
42
+ * shared as this call will no-op if the status is already set (checked by by object reference).
41
43
* @param duration An optional duration in milliseconds of the status, when specified the status
42
44
* will remove itself when the duration elapses unless the status gets re-added.
43
45
*/
@@ -87,6 +89,11 @@ export class TerminalStatusList extends Disposable implements ITerminalStatusLis
87
89
const timeout = window . setTimeout ( ( ) => this . remove ( status ) , duration ) ;
88
90
this . _statusTimeouts . set ( status . id , timeout ) ;
89
91
}
92
+ const existingStatus = this . _statuses . get ( status . id ) ;
93
+ if ( existingStatus && existingStatus !== status ) {
94
+ this . _onDidRemoveStatus . fire ( existingStatus ) ;
95
+ this . _statuses . delete ( existingStatus . id ) ;
96
+ }
90
97
if ( ! this . _statuses . has ( status . id ) ) {
91
98
const oldPrimary = this . primary ;
92
99
this . _statuses . set ( status . id , status ) ;
@@ -95,11 +102,6 @@ export class TerminalStatusList extends Disposable implements ITerminalStatusLis
95
102
if ( oldPrimary !== newPrimary ) {
96
103
this . _onDidChangePrimaryStatus . fire ( newPrimary ) ;
97
104
}
98
- } else {
99
- this . _statuses . set ( status . id , status ) ;
100
- // It maybe the case that status hasn't changed, there isn't a good way to check this based on
101
- // `ITerminalStatus`, so just fire the event anyway.
102
- this . _onDidAddStatus . fire ( status ) ;
103
105
}
104
106
}
105
107
0 commit comments