use await instead
This commit is contained in:
parent
2f82a84d2a
commit
91dd61b9a6
@ -125,12 +125,11 @@ export function joinLines(ctx: Ctx): Cmd {
|
||||
ranges: editor.selections.map((it) => client.code2ProtocolConverter.asRange(it)),
|
||||
textDocument: ctx.client.code2ProtocolConverter.asTextDocumentIdentifier(editor.document),
|
||||
});
|
||||
editor.edit((builder) => {
|
||||
await editor.edit((builder) => {
|
||||
client.protocol2CodeConverter.asTextEdits(items).forEach((edit: any) => {
|
||||
builder.replace(edit.range, edit.newText);
|
||||
});
|
||||
})
|
||||
.then(() => { }, console.error);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
@ -237,7 +236,7 @@ export function ssr(ctx: Ctx): Cmd {
|
||||
const request = await vscode.window.showInputBox(options);
|
||||
if (!request) return;
|
||||
|
||||
vscode.window.withProgress({
|
||||
await vscode.window.withProgress({
|
||||
location: vscode.ProgressLocation.Notification,
|
||||
title: "Structured search replace in progress...",
|
||||
cancellable: false,
|
||||
@ -247,8 +246,7 @@ export function ssr(ctx: Ctx): Cmd {
|
||||
});
|
||||
|
||||
await vscode.workspace.applyEdit(client.protocol2CodeConverter.asWorkspaceEdit(edit));
|
||||
})
|
||||
.then(() => { }, console.error);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
@ -459,16 +457,15 @@ export function reloadWorkspace(ctx: Ctx): Cmd {
|
||||
}
|
||||
|
||||
export function showReferences(ctx: Ctx): Cmd {
|
||||
return (uri: string, position: lc.Position, locations: lc.Location[]) => {
|
||||
return async (uri: string, position: lc.Position, locations: lc.Location[]) => {
|
||||
const client = ctx.client;
|
||||
if (client) {
|
||||
vscode.commands.executeCommand(
|
||||
await vscode.commands.executeCommand(
|
||||
'editor.action.showReferences',
|
||||
vscode.Uri.parse(uri),
|
||||
client.protocol2CodeConverter.asPosition(position),
|
||||
locations.map(client.protocol2CodeConverter.asLocation),
|
||||
)
|
||||
.then(() => { }, console.error);
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -477,11 +474,10 @@ export function applyActionGroup(_ctx: Ctx): Cmd {
|
||||
return async (actions: { label: string; arguments: lc.CodeAction }[]) => {
|
||||
const selectedAction = await vscode.window.showQuickPick(actions);
|
||||
if (!selectedAction) return;
|
||||
vscode.commands.executeCommand(
|
||||
await vscode.commands.executeCommand(
|
||||
'rust-analyzer.resolveCodeAction',
|
||||
selectedAction.arguments,
|
||||
)
|
||||
.then(() => { }, console.error);
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
@ -514,8 +510,7 @@ export function openDocs(ctx: Ctx): Cmd {
|
||||
const doclink = await client.sendRequest(ra.openDocs, { position, textDocument });
|
||||
|
||||
if (doclink != null) {
|
||||
vscode.commands.executeCommand("vscode.open", vscode.Uri.parse(doclink))
|
||||
.then(() => { }, console.error);
|
||||
await vscode.commands.executeCommand("vscode.open", vscode.Uri.parse(doclink));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -77,9 +77,8 @@ async function getDebugConfiguration(ctx: Ctx, runnable: ra.Runnable): Promise<v
|
||||
}
|
||||
|
||||
if (!debugEngine) {
|
||||
vscode.window.showErrorMessage(`Install [CodeLLDB](https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb)`
|
||||
+ ` or [MS C++ tools](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools) extension for debugging.`)
|
||||
.then(() => { }, console.error);
|
||||
await vscode.window.showErrorMessage(`Install [CodeLLDB](https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb)`
|
||||
+ ` or [MS C++ tools](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools) extension for debugging.`);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -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<string
|
||||
};
|
||||
const platform = platforms[`${process.arch} ${process.platform}`];
|
||||
if (platform === undefined) {
|
||||
vscode.window.showErrorMessage(
|
||||
await vscode.window.showErrorMessage(
|
||||
"Unfortunately we don't ship binaries for your platform yet. " +
|
||||
"You need to manually clone rust-analyzer repository and " +
|
||||
"run `cargo xtask install --server` to build the language server from sources. " +
|
||||
"If you feel that your platform should be supported, please create an issue " +
|
||||
"about that [here](https://github.com/rust-analyzer/rust-analyzer/issues) and we " +
|
||||
"will consider it."
|
||||
).then(() => { }, console.error);
|
||||
);
|
||||
return undefined;
|
||||
}
|
||||
const ext = platform.indexOf("-windows-") !== -1 ? ".exe" : "";
|
||||
|
@ -45,8 +45,7 @@ export async function selectRunnable(ctx: Ctx, prevRunnable?: RunnableQuickPick,
|
||||
if (items.length === 0) {
|
||||
// it is the debug case, run always has at least 'cargo check ...'
|
||||
// see crates\rust-analyzer\src\main_loop\handlers.rs, handle_runnables
|
||||
vscode.window.showErrorMessage("There's no debug target!")
|
||||
.then(() => { }, console.error);
|
||||
await vscode.window.showErrorMessage("There's no debug target!");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -66,8 +65,8 @@ export async function selectRunnable(ctx: Ctx, prevRunnable?: RunnableQuickPick,
|
||||
disposables.push(
|
||||
quickPick.onDidHide(() => close()),
|
||||
quickPick.onDidAccept(() => close(quickPick.selectedItems[0])),
|
||||
quickPick.onDidTriggerButton((_button) => {
|
||||
makeDebugConfig(ctx, quickPick.activeItems[0].runnable).catch(console.error);
|
||||
quickPick.onDidTriggerButton(async (_button) => {
|
||||
await makeDebugConfig(ctx, quickPick.activeItems[0].runnable);
|
||||
close();
|
||||
}),
|
||||
quickPick.onDidChangeActive((active) => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user