Skip to content

Commit

Permalink
Fix js/ts cross code block intellisense (#213726)
Browse files Browse the repository at this point in the history
We need to register support for the backing copilot scheme too, not just the panel scheme in core
  • Loading branch information
mjbvz authored May 28, 2024
1 parent 7f40fe4 commit d0d79c2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,13 @@ export const vsls = 'vsls';
export const walkThroughSnippet = 'walkThroughSnippet';
export const vscodeNotebookCell = 'vscode-notebook-cell';
export const officeScript = 'office-script';

/** Used for code blocks in chat by vs code core */
export const chatCodeBlock = 'vscode-chat-code-block';

/** Used for code blocks in chat by copilot. */
export const chatBackingCodeBlock = 'vscode-copilot-chat-code-block';

export function getSemanticSupportedSchemes() {
if (isWeb() && vscode.workspace.workspaceFolders) {
return vscode.workspace.workspaceFolders.map(folder => folder.uri.scheme);
Expand All @@ -30,6 +35,7 @@ export function getSemanticSupportedSchemes() {
walkThroughSnippet,
vscodeNotebookCell,
chatCodeBlock,
chatBackingCodeBlock,
];
}

Expand All @@ -42,3 +48,8 @@ export const disabledSchemes = new Set([
github,
azurerepos,
]);

export function isOfScheme(uri: vscode.Uri, ...schemes: string[]): boolean {
const normalizedUriScheme = uri.scheme.toLowerCase();
return schemes.some(scheme => normalizedUriScheme === scheme);
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class TypeScriptWorkspaceSymbolProvider implements vscode.WorkspaceSymbolProvide
}

const uri = this.client.toResource(item.file);
if (uri.scheme === fileSchemes.chatCodeBlock) {
if (fileSchemes.isOfScheme(uri, fileSchemes.chatCodeBlock, fileSchemes.chatBackingCodeBlock)) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ class SyncedBuffer {
return tsRoot?.startsWith(inMemoryResourcePrefix) ? undefined : tsRoot;
}

return resource.scheme === fileSchemes.officeScript || resource.scheme === fileSchemes.chatCodeBlock ? '/' : undefined;
return fileSchemes.isOfScheme(resource, fileSchemes.officeScript, fileSchemes.chatCodeBlock, fileSchemes.chatBackingCodeBlock) ? '/' : undefined;
}

public get resource(): vscode.Uri {
Expand Down Expand Up @@ -752,7 +752,7 @@ export default class BufferSyncSupport extends Disposable {
}

private shouldValidate(buffer: SyncedBuffer): boolean {
if (buffer.resource.scheme === fileSchemes.chatCodeBlock) {
if (fileSchemes.isOfScheme(buffer.resource, fileSchemes.chatCodeBlock, fileSchemes.chatBackingCodeBlock)) {
return false;
}

Expand Down

0 comments on commit d0d79c2

Please sign in to comment.