From 45b7b6a60a7404d093f4afe81a0da10824cef7b8 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Fri, 19 Aug 2022 08:52:31 +0200 Subject: Implement lsp extension for cancelling running flychecks --- editors/code/src/commands.ts | 6 ++++++ editors/code/src/lsp_ext.ts | 30 +++++++++++++++++------------- editors/code/src/main.ts | 1 + 3 files changed, 24 insertions(+), 13 deletions(-) (limited to 'editors/code/src') diff --git a/editors/code/src/commands.ts b/editors/code/src/commands.ts index 12f666401fd..a21b304bbda 100644 --- a/editors/code/src/commands.ts +++ b/editors/code/src/commands.ts @@ -817,6 +817,12 @@ export function openDocs(ctx: Ctx): Cmd { }; } +export function cancelFlycheck(ctx: Ctx): Cmd { + return async () => { + await ctx.client.sendRequest(ra.cancelFlycheck); + }; +} + export function resolveCodeAction(ctx: Ctx): Cmd { const client = ctx.client; return async (params: lc.CodeAction) => { diff --git a/editors/code/src/lsp_ext.ts b/editors/code/src/lsp_ext.ts index f80af78a74a..875261c48a6 100644 --- a/editors/code/src/lsp_ext.ts +++ b/editors/code/src/lsp_ext.ts @@ -75,6 +75,23 @@ export const expandMacro = new lc.RequestType( + "rust-analyzer/relatedTests" +); + +export const cancelFlycheck = new lc.RequestType0("rust-analyzer/cancelFlycheck"); + +// Experimental extensions + +export interface SsrParams { + query: string; + parseOnly: boolean; + textDocument: lc.TextDocumentIdentifier; + position: lc.Position; + selections: readonly lc.Range[]; +} +export const ssr = new lc.RequestType("experimental/ssr"); + export interface MatchingBraceParams { textDocument: lc.TextDocumentIdentifier; positions: lc.Position[]; @@ -127,19 +144,6 @@ export interface TestInfo { runnable: Runnable; } -export const relatedTests = new lc.RequestType( - "rust-analyzer/relatedTests" -); - -export interface SsrParams { - query: string; - parseOnly: boolean; - textDocument: lc.TextDocumentIdentifier; - position: lc.Position; - selections: readonly lc.Range[]; -} -export const ssr = new lc.RequestType("experimental/ssr"); - export interface CommandLink extends lc.Command { /** * A tooltip for the command, when represented in the UI. diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts index d78b711a47a..a9847dd2a65 100644 --- a/editors/code/src/main.ts +++ b/editors/code/src/main.ts @@ -163,6 +163,7 @@ async function initCommonContext(context: vscode.ExtensionContext, ctx: Ctx) { ctx.registerCommand("peekTests", commands.peekTests); ctx.registerCommand("moveItemUp", commands.moveItemUp); ctx.registerCommand("moveItemDown", commands.moveItemDown); + ctx.registerCommand("cancelFlycheck", commands.cancelFlycheck); defaultOnEnter.dispose(); ctx.registerCommand("onEnter", commands.onEnter); -- cgit 1.4.1-3-g733a5