Skip to content
This repository was archived by the owner on Nov 28, 2022. It is now read-only.

Commit 7981993

Browse files
author
Tim Etchells
authored
Fix log showing problem and theia detection (#643)
eclipse-archived/codewind#3158 Signed-off-by: Tim Etchells <timetchells@ibm.com>
1 parent 5e63da8 commit 7981993

File tree

3 files changed

+28
-8
lines changed

3 files changed

+28
-8
lines changed

dev/src/CWExtensionContext.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ class CWExtensionContext implements vscode.ExtensionContext {
5050
private readonly vscContext: vscode.ExtensionContext,
5151
) {
5252
this.resourcesPath = path.join(vscContext.extensionPath, "res");
53-
this.isTheia = vscode.env.appName.toLowerCase().includes("theia");
5453
this.isChe = !!process.env[Constants.CHE_WORKSPACEID_ENVVAR];
54+
this.isTheia = this.isChe || vscode.env.appName.toLowerCase().includes("theia");
5555

5656
const thisExtension = vscode.extensions.getExtension("IBM.codewind")!;
5757
this.extensionVersion = thisExtension.packageJSON.version;

dev/src/codewind/project/logs/MCLogManager.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,12 @@ export default class MCLogManager {
118118
}
119119

120120
public async showAll(type: "background" | "foreground"): Promise<void> {
121-
Log.d("Showing all logs for " + this.project.name);
121+
Log.d(`Showing all logs for ${this.project.name} in the ${type}`);
122122
this.isShowingAll = type;
123123
this.logs.forEach((log) => log.createOutput(true));
124-
await this.toggleLogStreaming(true);
124+
if (this.logs.length > 0) {
125+
await this.toggleLogStreaming(true);
126+
}
125127
}
126128

127129
/**

dev/src/command/project/ManageLogsCmd.ts

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,21 +75,39 @@ async function manageLogsInner(project: Project, all?: "show" | "show-from-creat
7575
// https://github.com/eclipse-theia/theia/issues/5673
7676
// In theia, the strings are a little different because we can only manage one log at a time due to no canPickMany support.
7777
// Note that the MCLog's 'detail' field is only set in Theia.
78-
const placeHolder = CWExtensionContext.get().isTheia ?
78+
const isTheiaManageLogs = CWExtensionContext.get().isTheia;
79+
80+
const placeHolder = isTheiaManageLogs ?
7981
`Select a log to show or hide in the Output view` :
8082
`Select the logs you wish to see in the Output view`;
8183

82-
const logsToShow = await vscode.window.showQuickPick<MCLog>(logs, {
84+
const logsSelected = await vscode.window.showQuickPick<MCLog>(logs, {
8385
canPickMany: true,
8486
matchOnDescription: true,
8587
placeHolder,
8688
});
87-
// https://github.com/Microsoft/vscode/issues/64014
88-
// }) as (MCLog[] | undefined);
8989

90-
if (logsToShow == null) {
90+
if (logsSelected == null) {
91+
// cancelled
9192
return;
9293
}
9394

95+
let logsToShow;
96+
if (!isTheiaManageLogs) {
97+
logsToShow = logsSelected;
98+
}
99+
else {
100+
logsToShow = logs.filter((log) => {
101+
if (logsSelected.includes(log)) {
102+
// inside theia, we just toggle the one log that was selected
103+
Log.d(`Log ${log.logName} is the selected one; toggling`);
104+
return !log.isOpen;
105+
}
106+
// maintain the state for all the logs that are not the selected one
107+
Log.d(`Log ${log.logName} is not selected; maintaining state`);
108+
return log.isOpen;
109+
});
110+
}
111+
94112
await project.logManager.showSome(logsToShow, true);
95113
}

0 commit comments

Comments
 (0)