microsoft/vscode · error · Error
Please open a text editor to use the `#selection` variable.
Error message
Please open a text editor to use the `#selection` variable.
What it means
Error "Please open a text editor to use the `#selection` variable." thrown in microsoft/vscode.
Source
Thrown at extensions/copilot/src/extension/conversation/vscode-node/remoteAgents.ts:646
// Check whether we can send file and selection data implicitly
if (this.checkAuthorized(slug)) {
const { activeTextEditor } = this.tabsAndEditorsService;
if (activeTextEditor && variables.find(v => v.id.startsWith('vscode.implicit'))) {
await addFileReference(activeTextEditor.document, undefined, true);
await addSelectionReference(activeTextEditor, undefined, undefined, true);
hasSentImplicitSelectionReference = true;
}
}
for (const variable of variables) {
if (URI.isUri(variable.value)) {
const textDocument = await this.workspaceService.openTextDocument(variable.value);
await addFileReference(textDocument, variable.name);
} else if (variable.name === 'selection') {
const { activeTextEditor } = this.tabsAndEditorsService;
if (!activeTextEditor) {
throw new Error(l10n.t({ message: 'Please open a text editor to use the `#selection` variable.', comment: '{Locked=\'`#selection`\'}' }));
}
if (!hasSentImplicitSelectionReference) {
await addSelectionReference(activeTextEditor, variable.name, true);
}
} else if (variable.name === 'editor' && this.tabsAndEditorsService.activeTextEditor) {
await addFileReference(this.tabsAndEditorsService.activeTextEditor.document, variable.name);
}
}
// Always send the open GitHub repositories
if (!this.gitService.isInitialized) {
await this.gitService.initialize();
}
const repositories = this.gitService.repositories;
for (const repository of repositories) {
const repoId = getGitHubRepoInfoFromContext(repository)?.id;
if (!repoId) {
continue; // Not a GitHub repositoryView on GitHub (pinned to a94b963a32)
When it happens
Trigger: Thrown at extensions/copilot/src/extension/conversation/vscode-node/remoteAgents.ts:646 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of microsoft/vscode@a94b963a32 (2026-08-12).
Data as JSON: /api/errors/ea78fc4f1173be3c.
Report an issue: GitHub.