Skip to content

Commit 2a85a1a

Browse files
hayemaxijustinmk3
andauthored
fix: help > open logs may not work after interacting with other options (#4139)
* fix: help > open logs may not work after interacting with other options Problem: Interacting with other options in the Amazon Q and Explorer views ellipses menu can cause the view logs option (of the same tree) to open an empty file. Since this command and menu options are maintained in package.json only, vscode may not properly supply arguments which leads to the open logs command breaking. Solution: Validate input arguments to the open logs command. * refactor: update aws.viewLog comment and syntax Co-authored-by: Justin M. Keyes <[email protected]> * refactor: remove unused arg to openLogs() --------- Co-authored-by: Justin M. Keyes <[email protected]>
1 parent 4369134 commit 2a85a1a

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Bug Fix",
3+
"description": "Help > View Toolkit Logs opens an empty file if other menu items were interacted with first."
4+
}

src/shared/logger/commands.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,16 @@ export class Logging {
2828
viewLogsAtMessage: Commands.from(this).declareOpenLogId('aws.viewLogsAtMessage'),
2929
}
3030

31-
public constructor(private readonly defaultLogUri: vscode.Uri, private readonly logger: Logger) {}
31+
public constructor(private readonly logUri: vscode.Uri, private readonly logger: Logger) {}
3232

33-
public async openLogUri(logUri = this.defaultLogUri): Promise<vscode.TextEditor | undefined> {
34-
telemetry.toolkit_viewLogs.emit() // Perhaps add additional argument to know which log was viewed?
35-
36-
return vscode.window.showTextDocument(logUri)
33+
public async openLogUri(): Promise<vscode.TextEditor | undefined> {
34+
telemetry.toolkit_viewLogs.emit()
35+
return vscode.window.showTextDocument(this.logUri)
3736
}
3837

39-
public async openLogId(logId: number, logUri = this.defaultLogUri) {
40-
const msg = this.logger.getLogById(logId, logUri)
41-
const editor = await this.openLogUri(logUri)
38+
public async openLogId(logId: number) {
39+
const msg = this.logger.getLogById(logId, this.logUri)
40+
const editor = await this.openLogUri()
4241
if (!msg || !editor) {
4342
return
4443
}

0 commit comments

Comments
 (0)