-
Notifications
You must be signed in to change notification settings - Fork 0
fix: CodeLens registration leak, cancellation surfaced as error, LanguageModelError codes missing from messages #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -78,13 +78,13 @@ export class ExplanationProvider implements vscode.Disposable { | |
| if (err instanceof vscode.LanguageModelError) { | ||
| switch (err.code) { | ||
| case 'NoPermissions': | ||
| throw new Error('Copilot access denied. Please check your GitHub Copilot subscription.'); | ||
| throw new Error(`Copilot error (${err.code}): access denied. Please check your GitHub Copilot subscription.`); | ||
| case 'Blocked': | ||
| throw new Error('Copilot request was blocked. Please check your GitHub Copilot settings.'); | ||
| throw new Error(`Copilot error (${err.code}): request was blocked. Please check your GitHub Copilot settings.`); | ||
| case 'NotFound': | ||
| throw new Error('Copilot model not found. Please check your GitHub Copilot extension.'); | ||
| throw new Error(`Copilot error (${err.code}): model not found. Please check your GitHub Copilot extension.`); | ||
| case 'RequestFailed': | ||
| throw new Error('Copilot request failed. Please try again.'); | ||
| throw new Error(`Copilot error (${err.code}): request failed. Please try again.`); | ||
| default: | ||
| throw new Error(`Copilot error (${err.code}): ${err.message}. Please check your GitHub Copilot extension.`); | ||
| } | ||
|
|
@@ -93,6 +93,9 @@ export class ExplanationProvider implements vscode.Disposable { | |
| } | ||
|
|
||
| result = result.trim(); | ||
| if (token.isCancellationRequested) { | ||
| throw new vscode.CancellationError(); | ||
| } | ||
|
Comment on lines
+96
to
+98
|
||
| if (!result) { | ||
| throw new Error('Copilot returned an empty explanation. Please try again.'); | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new
CancellationErrorthrown whentoken.isCancellationRequestedis true after streaming (line 96-98) propagates to callers that do not specifically handle it. InrunExplain(extension.ts ~line 310), the genericcatch (err)block catches theCancellationErrorand shows a user-visible error message like "Source Doc: Canceled". InexplainFile, the cancellation errors accumulate in theresultsarray and cause a misleading "N line(s) failed" error message to appear at the end.The callers already guard against cancellation (the
if (!token.isCancellationRequested)checks afterexplain()returns), but they don't guard againstCancellationErrorbeing thrown. The fix should either check forerr instanceof vscode.CancellationErrorin both catch blocks and silently swallow it, or re-checktoken.isCancellationRequestedin the callers' catch blocks before showing the error.