Skip to content
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

fix: handle zipfile uri with yarn pnp and neovim #179

Merged
merged 1 commit into from
Jul 3, 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
1 change: 1 addition & 0 deletions packages/server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ function onServerInitialize(conn: Connection, params: InitializeParams) {
locale: params.locale,
workspaceFolders: folders,
clientCapabilities,
hostInfo: params.initializationOptions?.hostInfo,
tsExtLogPath: params.initializationOptions?.tsLogPath,
});

Expand Down
62 changes: 62 additions & 0 deletions packages/service/patches/410-handle-yarn-zipfile.patch
Original file line number Diff line number Diff line change
@@ -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(/^\^\/([^\/]+)\/([^\/]*)\/(.+)$/);
1 change: 1 addition & 0 deletions packages/service/src/service/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export interface TSLanguageServiceOptions {
locale?: string;
workspaceFolders?: lsp.WorkspaceFolder[];
clientCapabilities: lsp.ClientCapabilities;
hostInfo?: string;
tsExtLogPath?: string;
}

Expand Down
3 changes: 2 additions & 1 deletion packages/service/src/shims/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion packages/service/src/shims/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Loading