diff --git a/packages/server/src/index.ts b/packages/server/src/index.ts index 6bf6f45..1407817 100644 --- a/packages/server/src/index.ts +++ b/packages/server/src/index.ts @@ -39,6 +39,7 @@ function onServerInitialize(conn: Connection, params: InitializeParams) { locale: params.locale, workspaceFolders: folders, clientCapabilities, + hostInfo: params.initializationOptions?.hostInfo, tsExtLogPath: params.initializationOptions?.tsLogPath, }); diff --git a/packages/service/patches/410-handle-yarn-zipfile.patch b/packages/service/patches/410-handle-yarn-zipfile.patch new file mode 100644 index 0000000..ecae801 --- /dev/null +++ b/packages/service/patches/410-handle-yarn-zipfile.patch @@ -0,0 +1,62 @@ +diff --git a/src/configuration/fileSchemes.ts b/src/configuration/fileSchemes.ts +index ca268e2..96c9f0b 100644 +--- a/src/configuration/fileSchemes.ts ++++ b/src/configuration/fileSchemes.ts +@@ -23,6 +23,7 @@ export const chatCodeBlock = 'vscode-chat-code-block'; + + /** Used for code blocks in chat by copilot. */ + export const chatBackingCodeBlock = 'vscode-copilot-chat-code-block'; ++export const zipfile = 'zipfile'; + + export function getSemanticSupportedSchemes() { + if (isWeb() && vscode.workspace.workspaceFolders) { +@@ -36,6 +37,7 @@ export function getSemanticSupportedSchemes() { + vscodeNotebookCell, + chatCodeBlock, + chatBackingCodeBlock, ++ zipfile + ]; + } + +diff --git a/src/typescriptServiceClient.ts b/src/typescriptServiceClient.ts +index 25dfca2..6330dd8 100644 +--- a/src/typescriptServiceClient.ts ++++ b/src/typescriptServiceClient.ts +@@ -572,7 +572,7 @@ export default class TypeScriptServiceClient extends Disposable implements IType + : undefined; + + const configureOptions: Proto.ConfigureRequestArguments = { +- hostInfo: 'vscode', ++ hostInfo: (this.context as any).hostInfo || 'vscode', + preferences: { + providePrefixAndSuffixTextForRename: true, + allowRenameOfImportPath: true, +@@ -748,6 +748,10 @@ export default class TypeScriptServiceClient extends Disposable implements IType + return resource.fsPath; + } + ++ if (resource.scheme === fileSchemes.zipfile) { ++ return resource.scheme + "://" + (resource.path.startsWith('/') ? resource.path : '/' + resource.path); ++ } ++ + return (this.isProjectWideIntellisenseOnWebEnabled() ? '' : inMemoryResourcePrefix) + + '/' + resource.scheme + + '/' + (resource.authority || emptyAuthority) +@@ -796,6 +800,17 @@ export default class TypeScriptServiceClient extends Disposable implements IType + return this.bufferSyncSupport.toVsCodeResource(resource); + } + } ++ if (filepath.startsWith(fileSchemes.zipfile)) { ++ const uri = vscode.Uri.parse(filepath, false) ++ return new Proxy(uri, { ++ get(target, p) { ++ if (p === 'toString') { ++ return () => filepath; ++ } ++ return target[p as keyof vscode.Uri]; ++ } ++ }) ++ } + + if (filepath.startsWith(inMemoryResourcePrefix)) { + const parts = filepath.match(/^\^\/([^\/]+)\/([^\/]*)\/(.+)$/); diff --git a/packages/service/src/service/types.ts b/packages/service/src/service/types.ts index f90ec95..c4be9d8 100644 --- a/packages/service/src/service/types.ts +++ b/packages/service/src/service/types.ts @@ -4,6 +4,7 @@ export interface TSLanguageServiceOptions { locale?: string; workspaceFolders?: lsp.WorkspaceFolder[]; clientCapabilities: lsp.ClientCapabilities; + hostInfo?: string; tsExtLogPath?: string; } diff --git a/packages/service/src/shims/context.ts b/packages/service/src/shims/context.ts index 2449f89..0fab2a3 100644 --- a/packages/service/src/shims/context.ts +++ b/packages/service/src/shims/context.ts @@ -2,9 +2,10 @@ import * as vscode from "vscode"; import { URI } from "vscode-uri"; import { Memento } from "./memento"; -export function createContextShim(logPath: string) { +export function createContextShim(logPath: string, hostInfo?: string) { return { logPath, + hostInfo, subscriptions: [], workspaceState: new Memento(), globalState: new Memento(), diff --git a/packages/service/src/shims/index.ts b/packages/service/src/shims/index.ts index f3ef68a..0227dae 100644 --- a/packages/service/src/shims/index.ts +++ b/packages/service/src/shims/index.ts @@ -53,7 +53,7 @@ export function initializeShimServices( const diagnosticsSerivce = new DiagnosticsShimService(); const languageFeaturesService = new LanguageFeaturesShimService(delegate, diagnosticsSerivce); const windowService = new WindowShimService(delegate); - const context = createContextShim(initOptions.tsExtLogPath ?? os.tmpdir()); + const context = createContextShim(initOptions.tsExtLogPath ?? os.tmpdir(), initOptions.hostInfo); const dispose = () => { configurationService.dispose();