Skip to content
This repository was archived by the owner on Nov 18, 2022. It is now read-only.

Commit 6e9ac77

Browse files
bors[bot]BGluthdavidlattimoreVeetahafannheyward
authored
Merge #5089 #5161 #5184 #5185 #5186
5089: Disable auto-complete on comments r=matklad a=BGluth Resolves #4907 by disabling any auto-completion on comments. As flodiebold [pointed out](rust-lang/rust-analyzer#4907 (comment)), in the future we may want to support some form of auto-completion within doc comments, but for now it was suggested to just disable auto-completion on them entirely. The implementation involves adding a new field `is_comment` to `CompletionContext` and checking if the immediate token we auto-completed on is a comment. I couldn't see a case where we need to check any of the ancestors, but let me know if this is not sufficient. I also wasn't sure if it was necessary to add a new field to this struct, but I decided it's probably the best option if we want to potentially do auto-completion on doc comments in the future. Finally, the three tests I added should I think ideally not filter results by `CompletionKind::Keyword`, but if I want to get unfiltered results, I need access to a non-public function [get_all_completion_items](https://github.com/rust-analyzer/rust-analyzer/blob/9a4d02faf9c47f401b8756c3f7fcab2198f5f9cd/crates/ra_ide/src/completion/test_utils.rs#L32-L39) which I don't know if I should make public just for this. 5161: SSR: Add initial support for placeholder constraints r=matklad a=davidlattimore 5184: Always install required nightly extension if current one is not nightly r=matklad a=Veetaha This is weird, but having switched back to stable by uninstalling the extension appears that vscode doesn't destroy the `PersistentState` and thus changing to `nightly` channel doesn't work because the last check for nightly extension was less than 1 hour ago. The simple solution is to skip this check if we know that the current extension version is not nightly. 5185: Force showing extension activation error pop-up notification r=matklad a=Veetaha Fixes rust-lang/rust-analyzer#5091 5186: fix: correct pd/ppd/tfn/tmod completion doc r=matklad a=fannheyward https://github.com/rust-analyzer/rust-analyzer/blob/a33eefa3b26000b3018e6bb873f18dbe15ab4ab7/crates/ra_ide/src/completion/complete_snippet.rs#L23-L24 Co-authored-by: BGluth <[email protected]> Co-authored-by: David Lattimore <[email protected]> Co-authored-by: Veetaha <[email protected]> Co-authored-by: Heyward Fann <[email protected]>
3 parents abccc6c + 32a96fd + 1694a69 commit 6e9ac77

File tree

1 file changed

+19
-7
lines changed
  • rust-analyzer/editors/code/src

1 file changed

+19
-7
lines changed

rust-analyzer/editors/code/src/main.ts

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,16 @@ let ctx: Ctx | undefined;
1919
const RUST_PROJECT_CONTEXT_NAME = "inRustProject";
2020

2121
export async function activate(context: vscode.ExtensionContext) {
22+
// For some reason vscode not always shows pop-up error notifications
23+
// when an extension fails to activate, so we do it explicitly by ourselves.
24+
// FIXME: remove this bit of code once vscode fixes this issue: https://github.com/microsoft/vscode/issues/101242
25+
await tryActivate(context).catch(err => {
26+
void vscode.window.showErrorMessage(`Cannot activate rust-analyzer: ${err.message}`);
27+
throw err;
28+
});
29+
}
30+
31+
async function tryActivate(context: vscode.ExtensionContext) {
2232
// Register a "dumb" onEnter command for the case where server fails to
2333
// start.
2434
//
@@ -58,9 +68,7 @@ export async function activate(context: vscode.ExtensionContext) {
5868

5969
const workspaceFolder = vscode.workspace.workspaceFolders?.[0];
6070
if (workspaceFolder === undefined) {
61-
const err = "Cannot activate rust-analyzer when no folder is opened";
62-
void vscode.window.showErrorMessage(err);
63-
throw new Error(err);
71+
throw new Error("no folder is opened");
6472
}
6573

6674
// Note: we try to start the server before we activate type hints so that it
@@ -152,13 +160,17 @@ async function bootstrapExtension(config: Config, state: PersistentState): Promi
152160
return;
153161
};
154162

155-
const lastCheck = state.lastCheck;
156163
const now = Date.now();
164+
if (config.package.releaseTag === NIGHTLY_TAG) {
165+
// Check if we should poll github api for the new nightly version
166+
// if we haven't done it during the past hour
167+
const lastCheck = state.lastCheck;
157168

158-
const anHour = 60 * 60 * 1000;
159-
const shouldDownloadNightly = state.releaseId === undefined || (now - (lastCheck ?? 0)) > anHour;
169+
const anHour = 60 * 60 * 1000;
170+
const shouldCheckForNewNightly = state.releaseId === undefined || (now - (lastCheck ?? 0)) > anHour;
160171

161-
if (!shouldDownloadNightly) return;
172+
if (!shouldCheckForNewNightly) return;
173+
}
162174

163175
const release = await fetchRelease("nightly").catch((e) => {
164176
log.error(e);

0 commit comments

Comments
 (0)