@@ -8,23 +8,30 @@ import Translator from "../../constants/strings/translator";
88/**
99 * Type to capture common functionality between AppLogs and BuildLogs
1010 */
11- export class MCLog {
11+ export class MCLog implements vscode . QuickPickItem {
1212
1313 protected static readonly STRING_NS : StringNamespaces = StringNamespaces . LOGS ;
1414
1515 protected readonly outputChannel : vscode . OutputChannel ;
1616
1717 protected doUpdate : boolean = true ;
1818
19+ // quickPickItem
20+ public readonly label : string ;
21+
1922 protected constructor (
2023 public readonly projectID : string ,
2124 public readonly projectName : string ,
22- initialMsg : string ,
23- private readonly logType : MCLog . LogTypes
25+ public readonly logType : MCLog . LogTypes ,
26+ private readonly managerMap : Map < string , MCLog > ,
27+ initialMsg : string
2428 ) {
2529 const outputChannelName = Translator . t ( MCLog . STRING_NS , "logName" , { projectName, logType : logType . toString ( ) } ) ;
2630 this . outputChannel = vscode . window . createOutputChannel ( outputChannelName ) ;
2731 this . outputChannel . appendLine ( initialMsg ) ;
32+
33+ // quickPickItem
34+ this . label = this . outputChannel . name ;
2835 }
2936
3037 public async showOutputChannel ( ) : Promise < void > {
@@ -39,7 +46,7 @@ export class MCLog {
3946 * A slightly different message is displayed if the updates were cancelled because we lost the MC connection.
4047 * It is possible for a user to manually stop the updates of a build log, in which case this should be false.
4148 */
42- public async stopUpdating ( connectionLost : boolean = true ) : Promise < void > {
49+ public stopUpdating ( connectionLost : boolean = true ) : void {
4350 if ( ! this . doUpdate ) {
4451 Log . d ( "Already stopped updating log " + this . outputChannel . name ) ;
4552 return ;
@@ -56,10 +63,17 @@ export class MCLog {
5663 this . outputChannel . appendLine ( "\n" + msg ) ; // non-nls
5764 }
5865
59- public async destroy ( ) : Promise < void > {
66+ /**
67+ * Disposes of this log's OutputChannel.
68+ * Also removes it from the owner manager's log map, which is a nasty coupling I will revisit!
69+ */
70+ public destroy ( ) : void {
6071 Log . d ( "Destroy log " + this . outputChannel . name ) ;
6172 this . stopUpdating ( ) ;
6273 this . outputChannel . dispose ( ) ;
74+ if ( this . managerMap . has ( this . projectID ) ) {
75+ this . managerMap . delete ( this . projectID ) ;
76+ }
6377 }
6478
6579 /**
0 commit comments