From 5f2d8f0c4205b29c91c525ddd55ca0254310ec3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Mangeonjean?= Date: Mon, 15 Apr 2024 18:25:26 +0200 Subject: [PATCH 1/3] fix: use custom languagedetection build that better supports the browser --- demo/package-lock.json | 2 +- package-lock.json | 9 +++++---- package.json | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/demo/package-lock.json b/demo/package-lock.json index cefe7df1..dddd8889 100644 --- a/demo/package-lock.json +++ b/demo/package-lock.json @@ -1041,7 +1041,7 @@ "version": "0.0.0-semantic-release", "license": "MIT", "dependencies": { - "@vscode/vscode-languagedetection": "1.0.21", + "@vscode/vscode-languagedetection": "npm:@codingame/vscode-languagedetection@1.0.23", "vscode": "npm:@codingame/monaco-vscode-api@^0.0.0-semantic-release" } }, diff --git a/package-lock.json b/package-lock.json index 8f2059ec..33521f0e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,7 +15,7 @@ "@vscode/proxy-agent": "^0.19.0", "@vscode/ripgrep": "^1.15.9", "@vscode/spdlog": "^0.15.0", - "@vscode/vscode-languagedetection": "1.0.21", + "@vscode/vscode-languagedetection": "npm:@codingame/vscode-languagedetection@1.0.23", "@vscode/windows-process-tree": "^0.6.0", "@vscode/windows-registry": "^1.1.0", "@xterm/addon-canvas": "0.7.0-beta.12", @@ -3902,9 +3902,10 @@ } }, "node_modules/@vscode/vscode-languagedetection": { - "version": "1.0.21", - "resolved": "https://registry.npmjs.org/@vscode/vscode-languagedetection/-/vscode-languagedetection-1.0.21.tgz", - "integrity": "sha512-zSUH9HYCw5qsCtd7b31yqkpaCU6jhtkKLkvOOA8yTrIRfBSOFb8PPhgmMicD7B/m+t4PwOJXzU1XDtrM9Fd3/g==", + "name": "@codingame/vscode-languagedetection", + "version": "1.0.23", + "resolved": "https://registry.npmjs.org/@codingame/vscode-languagedetection/-/vscode-languagedetection-1.0.23.tgz", + "integrity": "sha512-PqMisj1WEb1d9YtFapOjDQYACq8HD3f5/d+tFfZltsqAomGvoQxl7LBtftPUDT4zpvxls0IsJHiWrR/wvwyuzg==", "bin": { "vscode-languagedetection": "cli/index.js" } diff --git a/package.json b/package.json index 41d61b64..d8de3501 100644 --- a/package.json +++ b/package.json @@ -108,7 +108,7 @@ "@vscode/proxy-agent": "^0.19.0", "@vscode/ripgrep": "^1.15.9", "@vscode/spdlog": "^0.15.0", - "@vscode/vscode-languagedetection": "1.0.21", + "@vscode/vscode-languagedetection": "npm:@codingame/vscode-languagedetection@1.0.23", "@vscode/windows-process-tree": "^0.6.0", "@vscode/windows-registry": "^1.1.0", "@xterm/addon-canvas": "0.7.0-beta.12", From 36c9c231743c8ac4838e703bb4252c6f6febfb2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Mangeonjean?= Date: Mon, 15 Apr 2024 18:27:25 +0200 Subject: [PATCH 2/3] cleanup: remove unused parameter --- src/service-override/files.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/service-override/files.ts b/src/service-override/files.ts index 864d7d98..3c6ac8fd 100644 --- a/src/service-override/files.ts +++ b/src/service-override/files.ts @@ -324,7 +324,7 @@ class OverlayFileSystemProvider implements IFileSystemProviderWithFileReadWriteC throw firstError } - private async writeToDelegates (resource: URI, caller: (delegate: IFileSystemProviderWithFileReadWriteCapability) => Promise): Promise { + private async writeToDelegates (caller: (delegate: IFileSystemProviderWithFileReadWriteCapability) => Promise): Promise { for (const provider of this.delegates) { if ((provider.capabilities & FileSystemProviderCapabilities.Readonly) > 0) { continue @@ -378,7 +378,7 @@ class OverlayFileSystemProvider implements IFileSystemProviderWithFileReadWriteC } async writeFile (resource: URI, content: Uint8Array, opts: IFileWriteOptions): Promise { - await this.writeToDelegates(resource, async delegate => { + await this.writeToDelegates(async delegate => { try { const stats = await delegate.stat(resource) if (((stats.permissions ?? 0) & FilePermission.Readonly) > 0) { @@ -392,15 +392,15 @@ class OverlayFileSystemProvider implements IFileSystemProviderWithFileReadWriteC } async mkdir (resource: URI): Promise { - await this.writeToDelegates(resource, delegate => delegate.mkdir(resource)) + await this.writeToDelegates(delegate => delegate.mkdir(resource)) } async delete (resource: URI, opts: IFileDeleteOptions): Promise { - await this.writeToDelegates(resource, delegate => delegate.delete(resource, opts)) + await this.writeToDelegates(delegate => delegate.delete(resource, opts)) } async rename (from: URI, to: URI, opts: IFileOverwriteOptions): Promise { - await this.writeToDelegates(from, delegate => delegate.rename(from, to, opts)) + await this.writeToDelegates(delegate => delegate.rename(from, to, opts)) } } From 14e4e3ae21ab88c7752b87b2ac633794b1232c3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Mangeonjean?= Date: Mon, 15 Apr 2024 18:29:06 +0200 Subject: [PATCH 3/3] fix: do not immediately ignore thrown error --- src/service-override/files.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/service-override/files.ts b/src/service-override/files.ts index 3c6ac8fd..79487c23 100644 --- a/src/service-override/files.ts +++ b/src/service-override/files.ts @@ -379,14 +379,15 @@ class OverlayFileSystemProvider implements IFileSystemProviderWithFileReadWriteC async writeFile (resource: URI, content: Uint8Array, opts: IFileWriteOptions): Promise { await this.writeToDelegates(async delegate => { + let stats: IStat | undefined try { - const stats = await delegate.stat(resource) - if (((stats.permissions ?? 0) & FilePermission.Readonly) > 0) { - throw createFileSystemProviderError('Not allowed', FileSystemProviderErrorCode.NoPermissions) - } + stats = await delegate.stat(resource) } catch (err) { // ignore } + if (stats != null && ((stats.permissions ?? 0) & FilePermission.Readonly) > 0) { + throw createFileSystemProviderError('Not allowed', FileSystemProviderErrorCode.NoPermissions) + } return delegate.writeFile(resource, content, opts) }) }