Add progress reporting

This commit is contained in:
vsrs 2021-02-27 21:07:23 +03:00
parent 669e117644
commit 45d4e6b639
2 changed files with 25 additions and 17 deletions

View file

@ -1164,7 +1164,14 @@
"command": "rust-analyzer.openCargoToml", "command": "rust-analyzer.openCargoToml",
"when": "inRustProject" "when": "inRustProject"
} }
],
"editor/context": [
{
"command": "rust-analyzer.peekTests",
"when": "inRustProject",
"group": "navigation@1000"
}
] ]
} }
} }
} }

View file

@ -566,24 +566,25 @@ export function peekTests(ctx: Ctx): Cmd {
const editor = ctx.activeRustEditor; const editor = ctx.activeRustEditor;
if (!editor || !client) return; if (!editor || !client) return;
const uri = editor.document.uri.toString(); await vscode.window.withProgress({
const position = client.code2ProtocolConverter.asPosition( location: vscode.ProgressLocation.Notification,
editor.selection.active, title: "Looking for tests...",
); cancellable: false,
}, async (_progress, _token) => {
const tests = await client.sendRequest(ra.relatedTests, { const uri = editor.document.uri.toString();
textDocument: { uri: uri }, const position = client.code2ProtocolConverter.asPosition(
position: position, editor.selection.active,
}); );
const locations: lc.Location[] = tests.map( it => { const tests = await client.sendRequest(ra.relatedTests, {
return { textDocument: { uri: uri },
uri: it.runnable.location!.targetUri, position: position,
range: it.runnable.location!.targetSelectionRange });
}; const locations: lc.Location[] = tests.map(it =>
}); lc.Location.create(it.runnable.location!.targetUri, it.runnable.location!.targetSelectionRange));
await showReferencesImpl(client, uri, position, locations); await showReferencesImpl(client, uri, position, locations);
});
}; };
} }