From 6ce1ff5c6fb29784cf0fd99b84fa9e2cbe2b3944 Mon Sep 17 00:00:00 2001 From: GDR User Date: Sun, 22 Feb 2026 21:02:30 -0600 Subject: [PATCH] Fix percent-encoded drive letter colon (%3A) in Windows file URIs Some LSP clients send file URIs with the drive letter colon percent-encoded as %3A (e.g., file:///c%3A/Users/...). The existing _dosPathRegex only matches literal colons, causing getFilePath() to fail to strip the leading slash and decode the path correctly on Windows. - Update _dosPathRegex to also match %3A/%3a after the drive letter - Decode percent-encoded colon back to ':' after stripping the leading slash --- packages/pyright-internal/src/common/uri/uri.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/pyright-internal/src/common/uri/uri.ts b/packages/pyright-internal/src/common/uri/uri.ts index 6efbf2be0671..19801f444bf2 100644 --- a/packages/pyright-internal/src/common/uri/uri.ts +++ b/packages/pyright-internal/src/common/uri/uri.ts @@ -31,7 +31,7 @@ export type SerializedType = [UriKinds, ...any[]]; import type { Uri as UriInterface } from './uriInterface'; export interface Uri extends UriInterface {} -const _dosPathRegex = /^\/[a-zA-Z]:\//; +const _dosPathRegex = /^\/[a-zA-Z](?::|%3[aA])\//; const _win32NormalizationRegex = /\//g; // Returns just the fsPath path portion of a vscode URI. @@ -49,9 +49,11 @@ function getFilePath(uri: URI): string { } // If this is a DOS-style path with a drive letter, remove - // the leading slash. + // the leading slash and decode percent-encoded colons. if (filePath.match(_dosPathRegex)) { filePath = filePath.slice(1); + // Decode %3A/%3a back to ':' for Windows drive letters + filePath = filePath.replace(/^([a-zA-Z])%3[aA]/, '$1:'); } // vscode.URI normalizes the path to use the correct path separators.