From f80b52a68ce9b3931b0d58876b8ad799128e754a Mon Sep 17 00:00:00 2001 From: Jonathan Wang Date: Thu, 22 Aug 2019 19:41:40 -0700 Subject: [PATCH 1/2] Persist user's choice for Don't Show Again for New File command --- src/extension.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/extension.ts b/src/extension.ts index 37a6a3365..8b84022c5 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -31,7 +31,6 @@ let inDebugMode: boolean = false; let debuggerCommunicationHandler: DebuggerCommunicationServer; // Notification booleans let firstTimeClosed: boolean = true; -let shouldShowNewFile: boolean = true; let shouldShowInvalidFileNamePopup: boolean = true; let shouldShowRunCodePopup: boolean = true; export let outChannel: vscode.OutputChannel | undefined; @@ -238,6 +237,7 @@ export async function activate(context: vscode.ExtensionContext) { const fileName = "template.py"; const filePath = __dirname + path.sep + fileName; const file = fs.readFileSync(filePath, "utf8"); + const shouldShowNewFile: boolean = context.globalState.get("shouldShowNewFile", true); if (shouldShowNewFile) { vscode.window @@ -249,7 +249,7 @@ export async function activate(context: vscode.ExtensionContext) { ) .then((selection: vscode.MessageItem | undefined) => { if (selection === DialogResponses.DONT_SHOW) { - shouldShowNewFile = false; + context.globalState.update("shouldShowNewFile", false); telemetryAI.trackFeatureUsage( TelemetryEventName.CLICK_DIALOG_DONT_SHOW ); @@ -270,6 +270,7 @@ export async function activate(context: vscode.ExtensionContext) { }); } + context.globalState.update("shouldShowNewFile", true); // tslint:disable-next-line: ban-comma-operator vscode.workspace .openTextDocument({ content: file, language: "python" }) From 8e5963b6af9819a3eddd52b95f1df8d25d0a4186 Mon Sep 17 00:00:00 2001 From: Jonathan Wang Date: Thu, 22 Aug 2019 19:53:27 -0700 Subject: [PATCH 2/2] Use a better name for variable --- src/extension.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/extension.ts b/src/extension.ts index 8b84022c5..5ff5b0538 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -237,9 +237,9 @@ export async function activate(context: vscode.ExtensionContext) { const fileName = "template.py"; const filePath = __dirname + path.sep + fileName; const file = fs.readFileSync(filePath, "utf8"); - const shouldShowNewFile: boolean = context.globalState.get("shouldShowNewFile", true); + const shouldShowNewFilePopup: boolean = context.globalState.get("shouldShowNewFilePopup", true); - if (shouldShowNewFile) { + if (shouldShowNewFilePopup) { vscode.window .showInformationMessage( CONSTANTS.INFO.NEW_FILE, @@ -249,7 +249,7 @@ export async function activate(context: vscode.ExtensionContext) { ) .then((selection: vscode.MessageItem | undefined) => { if (selection === DialogResponses.DONT_SHOW) { - context.globalState.update("shouldShowNewFile", false); + context.globalState.update("shouldShowNewFilePopup", false); telemetryAI.trackFeatureUsage( TelemetryEventName.CLICK_DIALOG_DONT_SHOW ); @@ -270,7 +270,6 @@ export async function activate(context: vscode.ExtensionContext) { }); } - context.globalState.update("shouldShowNewFile", true); // tslint:disable-next-line: ban-comma-operator vscode.workspace .openTextDocument({ content: file, language: "python" })