diff options
| author | bors <bors@rust-lang.org> | 2022-12-16 22:06:35 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-12-16 22:06:35 +0000 |
| commit | e0aa5afd7bd69813154e97a25cb6c6b4f05ea1be (patch) | |
| tree | a35c90b485ae4c480a5573364439e19b8ce3b9f0 /editors/code | |
| parent | 19c2ede549d9a5ec91ec2c20e2b32abd3e6566d4 (diff) | |
| parent | a04feb915a0e5ef348075a3537a95875cb1b1ffe (diff) | |
| download | rust-e0aa5afd7bd69813154e97a25cb6c6b4f05ea1be.tar.gz rust-e0aa5afd7bd69813154e97a25cb6c6b4f05ea1be.zip | |
Auto merge of #13785 - Veykril:run-flycheck, r=Veykril
Add command for manually running flychecks Closes https://github.com/rust-lang/rust-analyzer/issues/13125
Diffstat (limited to 'editors/code')
| -rw-r--r-- | editors/code/package.json | 5 | ||||
| -rw-r--r-- | editors/code/src/commands.ts | 15 | ||||
| -rw-r--r-- | editors/code/src/lsp_ext.ts | 4 | ||||
| -rw-r--r-- | editors/code/src/main.ts | 1 |
4 files changed, 22 insertions, 3 deletions
diff --git a/editors/code/package.json b/editors/code/package.json index 5b83701a682..bfaad1edcea 100644 --- a/editors/code/package.json +++ b/editors/code/package.json @@ -246,6 +246,11 @@ "command": "rust-analyzer.cancelFlycheck", "title": "Cancel running flychecks", "category": "rust-analyzer" + }, + { + "command": "rust-analyzer.runFlycheck", + "title": "Run flycheck", + "category": "rust-analyzer" } ], "keybindings": [ diff --git a/editors/code/src/commands.ts b/editors/code/src/commands.ts index 312087e4cff..e0b4bb63c31 100644 --- a/editors/code/src/commands.ts +++ b/editors/code/src/commands.ts @@ -788,8 +788,17 @@ export function openDocs(ctx: CtxInit): Cmd { export function cancelFlycheck(ctx: CtxInit): Cmd { return async () => { + await ctx.client.sendRequest(ra.cancelFlycheck); + }; +} + +export function runFlycheck(ctx: CtxInit): Cmd { + return async () => { + const editor = ctx.activeRustEditor; const client = ctx.client; - await client.sendRequest(ra.cancelFlycheck); + const params = editor ? { uri: editor.document.uri.toString() } : null; + + await client.sendNotification(ra.runFlycheck, { textDocument: params }); }; } @@ -797,12 +806,12 @@ export function resolveCodeAction(ctx: CtxInit): Cmd { return async (params: lc.CodeAction) => { const client = ctx.client; params.command = undefined; - const item = await client?.sendRequest(lc.CodeActionResolveRequest.type, params); + const item = await client.sendRequest(lc.CodeActionResolveRequest.type, params); if (!item?.edit) { return; } const itemEdit = item.edit; - const edit = await client?.protocol2CodeConverter.asWorkspaceEdit(itemEdit); + const edit = await client.protocol2CodeConverter.asWorkspaceEdit(itemEdit); // filter out all text edits and recreate the WorkspaceEdit without them so we can apply // snippet edits on our own const lcFileSystemEdit = { diff --git a/editors/code/src/lsp_ext.ts b/editors/code/src/lsp_ext.ts index 875261c48a6..78da4e959c6 100644 --- a/editors/code/src/lsp_ext.ts +++ b/editors/code/src/lsp_ext.ts @@ -81,6 +81,10 @@ export const relatedTests = new lc.RequestType<lc.TextDocumentPositionParams, Te export const cancelFlycheck = new lc.RequestType0<void, void>("rust-analyzer/cancelFlycheck"); +export const runFlycheck = new lc.NotificationType<{ + textDocument: lc.TextDocumentIdentifier | null; +}>("rust-analyzer/runFlycheck"); + // Experimental extensions export interface SsrParams { diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts index 01a1a2db7fd..c5fc44b4f9f 100644 --- a/editors/code/src/main.ts +++ b/editors/code/src/main.ts @@ -150,6 +150,7 @@ function createCommands(): Record<string, CommandFactory> { moveItemUp: { enabled: commands.moveItemUp }, moveItemDown: { enabled: commands.moveItemDown }, cancelFlycheck: { enabled: commands.cancelFlycheck }, + runFlycheck: { enabled: commands.runFlycheck }, ssr: { enabled: commands.ssr }, serverVersion: { enabled: commands.serverVersion }, // Internal commands which are invoked by the server. |
