diff --git a/core/autocomplete/completionProvider.ts b/core/autocomplete/completionProvider.ts index 66ebf9cee..33b73ed5b 100644 --- a/core/autocomplete/completionProvider.ts +++ b/core/autocomplete/completionProvider.ts @@ -395,7 +395,7 @@ export async function getTabCompletion( if (llm.model.includes("codestral")) { // Codestral sometimes starts with an extra space if (completion[0] === " " && completion[1] !== " ") { - if (suffix.startsWith("\n")) { + if (prefix.endsWith(" ") && suffix.startsWith("\n")) { completion = completion.slice(1); } } diff --git a/extensions/vscode/src/ideProtocol.ts b/extensions/vscode/src/ideProtocol.ts index c8c003f95..3e7e5468b 100644 --- a/extensions/vscode/src/ideProtocol.ts +++ b/extensions/vscode/src/ideProtocol.ts @@ -45,9 +45,20 @@ class VsCodeIde implements IDE { private askedForAuth = false; async getGitHubAuthToken(): Promise { + // Saved auth token if (this.authToken) { return this.authToken; } + + // Try to ask silently + const session = await vscode.authentication.getSession("github", [], { + silent: true, + }); + if (session) { + this.authToken = session.accessToken; + return this.authToken; + } + try { // If we haven't asked yet, give explanation of what is happening and why // But don't wait to return this immediately @@ -90,6 +101,17 @@ class VsCodeIde implements IDE { "https://docs.continue.dev/reference/Model%20Providers/freetrial", ), ); + } else if (selection === "Sign in") { + const session = await vscode.authentication.getSession( + "github", + [], + { + createIfNone: true, + }, + ); + if (session) { + this.authToken = session.accessToken; + } } }); this.askedForAuth = true;