From 1bb4e973ffaffd78a01ba5abb90096d11a2ddb42 Mon Sep 17 00:00:00 2001 From: Sahandevs Date: Sun, 7 Feb 2021 21:52:32 +0330 Subject: handle Thenable type rejects --- editors/code/src/main.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'editors/code/src/main.ts') diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts index 1900d900a..a5c728b67 100644 --- a/editors/code/src/main.ts +++ b/editors/code/src/main.ts @@ -76,7 +76,8 @@ async function tryActivate(context: vscode.ExtensionContext) { // This a horribly, horribly wrong way to deal with this problem. ctx = await Ctx.create(config, context, serverPath, workspaceFolder.uri.fsPath); - setContextValue(RUST_PROJECT_CONTEXT_NAME, true); + setContextValue(RUST_PROJECT_CONTEXT_NAME, true) + .then(() => {}, console.error); // Commands which invokes manually via command palette, shortcut, etc. @@ -142,7 +143,8 @@ async function tryActivate(context: vscode.ExtensionContext) { } export async function deactivate() { - setContextValue(RUST_PROJECT_CONTEXT_NAME, undefined); + setContextValue(RUST_PROJECT_CONTEXT_NAME, undefined) + .then(() => {}, console.error); await ctx?.client.stop(); ctx = undefined; } @@ -186,7 +188,8 @@ async function bootstrapExtension(config: Config, state: PersistentState): Promi }).catch((e) => { log.error(e); if (state.releaseId === undefined) { // Show error only for the initial download - vscode.window.showErrorMessage(`Failed to download rust-analyzer nightly ${e}`); + vscode.window.showErrorMessage(`Failed to download rust-analyzer nightly ${e}`) + .then(() => {}, console.error); } return undefined; }); @@ -305,7 +308,7 @@ async function getServer(config: Config, state: PersistentState): Promise {}, console.error); return undefined; } const ext = platform.indexOf("-windows-") !== -1 ? ".exe" : ""; @@ -433,6 +436,7 @@ function warnAboutExtensionConflicts() { vscode.window.showWarningMessage( `You have both the ${fst[0]} (${fst[1]}) and ${sec[0]} (${sec[1]}) ` + "plugins enabled. These are known to conflict and cause various functions of " + - "both plugins to not work correctly. You should disable one of them.", "Got it"); + "both plugins to not work correctly. You should disable one of them.", "Got it") + .then(() => {}, console.error); }; } -- cgit v1.2.3 From 3a0234d60f924cdec4a3fa2fccfe7ed85567f0bc Mon Sep 17 00:00:00 2001 From: Sahandevs Date: Sun, 7 Feb 2021 21:59:06 +0330 Subject: format --- editors/code/src/main.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'editors/code/src/main.ts') diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts index a5c728b67..ecbe4e3c9 100644 --- a/editors/code/src/main.ts +++ b/editors/code/src/main.ts @@ -77,7 +77,7 @@ async function tryActivate(context: vscode.ExtensionContext) { ctx = await Ctx.create(config, context, serverPath, workspaceFolder.uri.fsPath); setContextValue(RUST_PROJECT_CONTEXT_NAME, true) - .then(() => {}, console.error); + .then(() => { }, console.error); // Commands which invokes manually via command palette, shortcut, etc. @@ -144,7 +144,7 @@ async function tryActivate(context: vscode.ExtensionContext) { export async function deactivate() { setContextValue(RUST_PROJECT_CONTEXT_NAME, undefined) - .then(() => {}, console.error); + .then(() => { }, console.error); await ctx?.client.stop(); ctx = undefined; } @@ -189,7 +189,7 @@ async function bootstrapExtension(config: Config, state: PersistentState): Promi log.error(e); if (state.releaseId === undefined) { // Show error only for the initial download vscode.window.showErrorMessage(`Failed to download rust-analyzer nightly ${e}`) - .then(() => {}, console.error); + .then(() => { }, console.error); } return undefined; }); @@ -308,7 +308,7 @@ async function getServer(config: Config, state: PersistentState): Promise {}, console.error); + ).then(() => { }, console.error); return undefined; } const ext = platform.indexOf("-windows-") !== -1 ? ".exe" : ""; @@ -437,6 +437,6 @@ function warnAboutExtensionConflicts() { `You have both the ${fst[0]} (${fst[1]}) and ${sec[0]} (${sec[1]}) ` + "plugins enabled. These are known to conflict and cause various functions of " + "both plugins to not work correctly. You should disable one of them.", "Got it") - .then(() => {}, console.error); + .then(() => { }, console.error); }; } -- cgit v1.2.3 From 91dd61b9a662caf628a376d1e3b52b56b7ee8d31 Mon Sep 17 00:00:00 2001 From: Sahandevs Date: Tue, 9 Feb 2021 17:42:46 +0330 Subject: use await instead --- editors/code/src/main.ts | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'editors/code/src/main.ts') diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts index ecbe4e3c9..5c0b0be26 100644 --- a/editors/code/src/main.ts +++ b/editors/code/src/main.ts @@ -76,8 +76,7 @@ async function tryActivate(context: vscode.ExtensionContext) { // This a horribly, horribly wrong way to deal with this problem. ctx = await Ctx.create(config, context, serverPath, workspaceFolder.uri.fsPath); - setContextValue(RUST_PROJECT_CONTEXT_NAME, true) - .then(() => { }, console.error); + await setContextValue(RUST_PROJECT_CONTEXT_NAME, true); // Commands which invokes manually via command palette, shortcut, etc. @@ -143,8 +142,7 @@ async function tryActivate(context: vscode.ExtensionContext) { } export async function deactivate() { - setContextValue(RUST_PROJECT_CONTEXT_NAME, undefined) - .then(() => { }, console.error); + await setContextValue(RUST_PROJECT_CONTEXT_NAME, undefined); await ctx?.client.stop(); ctx = undefined; } @@ -185,11 +183,10 @@ async function bootstrapExtension(config: Config, state: PersistentState): Promi const release = await downloadWithRetryDialog(state, async () => { return await fetchRelease("nightly", state.githubToken); - }).catch((e) => { + }).catch(async (e) => { log.error(e); if (state.releaseId === undefined) { // Show error only for the initial download - vscode.window.showErrorMessage(`Failed to download rust-analyzer nightly ${e}`) - .then(() => { }, console.error); + await vscode.window.showErrorMessage(`Failed to download rust-analyzer nightly ${e}`); } return undefined; }); @@ -301,14 +298,14 @@ async function getServer(config: Config, state: PersistentState): Promise { }, console.error); + ); return undefined; } const ext = platform.indexOf("-windows-") !== -1 ? ".exe" : ""; -- cgit v1.2.3