Skip to content

Fix js/ts cross code block intellisense #213726

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

Merged
merged 1 commit into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading