Skip to content

Commit 45d4e6b

Browse files
committed
Add progress reporting
1 parent 669e117 commit 45d4e6b

File tree

2 files changed

+25
-17
lines changed

2 files changed

+25
-17
lines changed

editors/code/package.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1164,7 +1164,14 @@
11641164
"command": "rust-analyzer.openCargoToml",
11651165
"when": "inRustProject"
11661166
}
1167+
],
1168+
"editor/context": [
1169+
{
1170+
"command": "rust-analyzer.peekTests",
1171+
"when": "inRustProject",
1172+
"group": "navigation@1000"
1173+
}
11671174
]
11681175
}
11691176
}
1170-
}
1177+
}

editors/code/src/commands.ts

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -566,24 +566,25 @@ export function peekTests(ctx: Ctx): Cmd {
566566
const editor = ctx.activeRustEditor;
567567
if (!editor || !client) return;
568568

569-
const uri = editor.document.uri.toString();
570-
const position = client.code2ProtocolConverter.asPosition(
571-
editor.selection.active,
572-
);
573-
574-
const tests = await client.sendRequest(ra.relatedTests, {
575-
textDocument: { uri: uri },
576-
position: position,
577-
});
569+
await vscode.window.withProgress({
570+
___location: vscode.ProgressLocation.Notification,
571+
title: "Looking for tests...",
572+
cancellable: false,
573+
}, async (_progress, _token) => {
574+
const uri = editor.document.uri.toString();
575+
const position = client.code2ProtocolConverter.asPosition(
576+
editor.selection.active,
577+
);
578578

579-
const locations: lc.Location[] = tests.map( it => {
580-
return {
581-
uri: it.runnable.___location!.targetUri,
582-
range: it.runnable.___location!.targetSelectionRange
583-
};
584-
});
579+
const tests = await client.sendRequest(ra.relatedTests, {
580+
textDocument: { uri: uri },
581+
position: position,
582+
});
583+
const locations: lc.Location[] = tests.map(it =>
584+
lc.Location.create(it.runnable.___location!.targetUri, it.runnable.___location!.targetSelectionRange));
585585

586-
await showReferencesImpl(client, uri, position, locations);
586+
await showReferencesImpl(client, uri, position, locations);
587+
});
587588
};
588589
}
589590

0 commit comments

Comments
 (0)