From 0913d923c0a2741fba03988ff6c8b83a4a9facd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Mangeonjean?= Date: Tue, 21 May 2024 16:58:12 +0200 Subject: [PATCH 1/3] doc: fix README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 236d1a52..34f6fa15 100644 --- a/README.md +++ b/README.md @@ -250,7 +250,7 @@ await initialize({ // Open a new editor here and return it // It will be called when for instance the user ctrl+click on an import }), - ...getConfigurationServiceOverride(vscode.Uri.file('/tmp/')) + ...getConfigurationServiceOverride() }) updateUserConfiguration(`{ From bcdd9c2765fb1ca850a2afb770ae8695a3f0d2d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Mangeonjean?= Date: Tue, 21 May 2024 16:58:25 +0200 Subject: [PATCH 2/3] fix: fix parent directory detection --- src/service-override/files.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/service-override/files.ts b/src/service-override/files.ts index 2fb39ab2..bd134741 100644 --- a/src/service-override/files.ts +++ b/src/service-override/files.ts @@ -111,6 +111,13 @@ class RegisteredMemoryFile extends RegisteredFile { } } +function addTrailingSlash (uri: string) { + if (!uri.endsWith('/')) { + return uri + '/' + } + return uri +} + const encoder = new TextEncoder() const decoder = new TextDecoder() class RegisteredFileSystemProvider extends Disposable implements IFileSystemProviderWithFileReadWriteCapability { @@ -183,7 +190,7 @@ class RegisteredFileSystemProvider extends Disposable implements IFileSystemProv } const handledUris = Array.from(this.files.keys()) for (const handledUri of handledUris) { - if (handledUri.startsWith(resourceUri + '/')) { + if (handledUri.startsWith(addTrailingSlash(resourceUri))) { return { ctime: Date.now(), mtime: Date.now(), @@ -199,7 +206,7 @@ class RegisteredFileSystemProvider extends Disposable implements IFileSystemProv public async readdir (resource: URI): Promise<[string, FileType][]> { const includedPaths = Array.from(this.files.keys()) .map(uri => URI.parse(uri)) - .filter(uri => uri.authority === resource.authority && uri.path.startsWith(resource.path + '/')) + .filter(uri => uri.authority === resource.authority && uri.path.startsWith(addTrailingSlash(resource.path))) .map(uri => extUri.relativePath(resource, uri)!) const files = includedPaths.filter(path => !path.includes('/')) From 1586b0e4fedeb0fec5e968aeed5e0e4eb767f3ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Mangeonjean?= Date: Tue, 21 May 2024 17:00:37 +0200 Subject: [PATCH 3/3] fix(demo): switch from /tmp to /workspace --- demo/src/features/debugger.ts | 4 ++-- demo/src/features/intellisense.ts | 6 +++--- demo/src/features/output.ts | 2 +- demo/src/features/scm.ts | 8 ++++---- demo/src/features/terminal.ts | 2 +- demo/src/main.common.ts | 4 ++-- demo/src/setup.common.ts | 22 +++++++++++----------- 7 files changed, 24 insertions(+), 24 deletions(-) diff --git a/demo/src/features/debugger.ts b/demo/src/features/debugger.ts index 08e8e2a0..8dc26ca2 100644 --- a/demo/src/features/debugger.ts +++ b/demo/src/features/debugger.ts @@ -64,9 +64,9 @@ void getApi().then(async debuggerVscodeApi => { }) websocket.send(JSON.stringify({ - main: '/tmp/test.js', + main: '/workspace/test.js', files: { - '/tmp/test.js': new TextDecoder().decode(await debuggerVscodeApi.workspace.fs.readFile(debuggerVscodeApi.Uri.file('/tmp/test.js'))) + '/workspace/test.js': new TextDecoder().decode(await debuggerVscodeApi.workspace.fs.readFile(debuggerVscodeApi.Uri.file('/workspace/test.js'))) } })) diff --git a/demo/src/features/intellisense.ts b/demo/src/features/intellisense.ts index e5f9cda6..9ce08dcb 100644 --- a/demo/src/features/intellisense.ts +++ b/demo/src/features/intellisense.ts @@ -22,7 +22,7 @@ void getApi().then(async api => { return { name: 'Fake call hierarchy', kind: api.SymbolKind.Class, - uri: api.Uri.file('/tmp/test.js'), + uri: api.Uri.file('/workspace/test.js'), range: new api.Range(0, 0, 0, 10), selectionRange: new api.Range(0, 0, 0, 10) } @@ -32,7 +32,7 @@ void getApi().then(async api => { from: { name: 'Fake incomming call', kind: api.SymbolKind.Class, - uri: api.Uri.file('/tmp/test.js'), + uri: api.Uri.file('/workspace/test.js'), range: new api.Range(0, 0, 0, 10), selectionRange: new api.Range(0, 0, 0, 10) }, @@ -71,7 +71,7 @@ void getApi().then(async api => { if (wordRange != null && document.getText(wordRange) === 'anotherfile') { return { range: wordRange, - uri: api.Uri.file('/tmp/test_readonly.js') + uri: api.Uri.file('/workspace/test_readonly.js') } } return [] diff --git a/demo/src/features/output.ts b/demo/src/features/output.ts index 55db2489..6290fd71 100644 --- a/demo/src/features/output.ts +++ b/demo/src/features/output.ts @@ -20,7 +20,7 @@ if (!useHtmlFileSystemProvider) { fakeOutputChannel.append('Hello world\n') }, 1000) - const mainDocument = await vscode.workspace.openTextDocument(vscode.Uri.file('/tmp/test.js')) + const mainDocument = await vscode.workspace.openTextDocument(vscode.Uri.file('/workspace/test.js')) anotherFakeOutputChannel.replace(mainDocument.getText()) vscode.workspace.onDidChangeTextDocument((e) => { if (e.document === mainDocument && e.contentChanges.length > 0) { diff --git a/demo/src/features/scm.ts b/demo/src/features/scm.ts index 66214723..ce16cd97 100644 --- a/demo/src/features/scm.ts +++ b/demo/src/features/scm.ts @@ -44,18 +44,18 @@ void getApi().then(async vscode => { const group = scm.createResourceGroup('working-tree', 'Working Tree') group.resourceStates = [{ - resourceUri: vscode.Uri.file('/tmp/test.js'), + resourceUri: vscode.Uri.file('/workspace/test.js'), command: { title: 'Commit', command: 'scm-demo.click-file', - arguments: [vscode.Uri.file('/tmp/test.js')] + arguments: [vscode.Uri.file('/workspace/test.js')] } }, { - resourceUri: vscode.Uri.file('/tmp/test_readonly.js'), + resourceUri: vscode.Uri.file('/workspace/test_readonly.js'), command: { title: 'Commit', command: 'scm-demo.click-file', - arguments: [vscode.Uri.file('/tmp/test_readonly.js')] + arguments: [vscode.Uri.file('/workspace/test_readonly.js')] }, decorations: { strikeThrough: true, diff --git a/demo/src/features/terminal.ts b/demo/src/features/terminal.ts index 73eeef9d..baaca9bc 100644 --- a/demo/src/features/terminal.ts +++ b/demo/src/features/terminal.ts @@ -55,6 +55,6 @@ export class TerminalBackend extends SimpleTerminalBackend { override clearBuffer (): void | Promise { } } - return new FakeTerminalProcess(1, 1, '/tmp', dataEmitter.event) + return new FakeTerminalProcess(1, 1, '/workspace', dataEmitter.event) } } diff --git a/demo/src/main.common.ts b/demo/src/main.common.ts index 564df072..167c4285 100644 --- a/demo/src/main.common.ts +++ b/demo/src/main.common.ts @@ -64,10 +64,10 @@ const { getApi } = registerExtension({ void getApi().then(async vscode => { if (!useHtmlFileSystemProvider) { - const mainModelUri = vscode.Uri.file('/tmp/test.js') + const mainModelUri = vscode.Uri.file('/workspace/test.js') await Promise.all([ vscode.workspace.openTextDocument(mainModelUri), - vscode.workspace.openTextDocument(monaco.Uri.file('/tmp/test_readonly.js')) // open the file so vscode sees it's locked + vscode.workspace.openTextDocument(monaco.Uri.file('/workspace/test_readonly.js')) // open the file so vscode sees it's locked ]) const diagnostics = vscode.languages.createDiagnosticCollection('demo') diff --git a/demo/src/setup.common.ts b/demo/src/setup.common.ts index a1da8878..569ce98e 100644 --- a/demo/src/setup.common.ts +++ b/demo/src/setup.common.ts @@ -91,7 +91,7 @@ if (useHtmlFileSystemProvider) { } else { const fileSystemProvider = new RegisteredFileSystemProvider(false) - fileSystemProvider.registerFile(new RegisteredMemoryFile(vscode.Uri.file('/tmp/test.js'), `// import anotherfile + fileSystemProvider.registerFile(new RegisteredMemoryFile(vscode.Uri.file('/workspace/test.js'), `// import anotherfile let variable = 1 function inc () { variable++ @@ -103,9 +103,9 @@ while (variable < 5000) { }` )) - fileSystemProvider.registerFile(new RegisteredReadOnlyFile(vscode.Uri.file('/tmp/test_readonly.js'), async () => 'This is a readonly static file')) + fileSystemProvider.registerFile(new RegisteredReadOnlyFile(vscode.Uri.file('/workspace/test_readonly.js'), async () => 'This is a readonly static file')) - fileSystemProvider.registerFile(new RegisteredMemoryFile(vscode.Uri.file('/tmp/jsconfig.json'), `{ + fileSystemProvider.registerFile(new RegisteredMemoryFile(vscode.Uri.file('/workspace/jsconfig.json'), `{ "compilerOptions": { "target": "es2020", "module": "esnext", @@ -117,7 +117,7 @@ while (variable < 5000) { }` )) - fileSystemProvider.registerFile(new RegisteredMemoryFile(vscode.Uri.file('/tmp/index.html'), ` + fileSystemProvider.registerFile(new RegisteredMemoryFile(vscode.Uri.file('/workspace/index.html'), ` @@ -137,7 +137,7 @@ while (variable < 5000) { ` )) - fileSystemProvider.registerFile(new RegisteredMemoryFile(vscode.Uri.file('/tmp/test.md'), ` + fileSystemProvider.registerFile(new RegisteredMemoryFile(vscode.Uri.file('/workspace/test.md'), ` ***Hello World*** Math block: @@ -160,11 +160,11 @@ $$ ` )) - fileSystemProvider.registerFile(new RegisteredMemoryFile(vscode.Uri.file('/tmp/test.customeditor'), ` + fileSystemProvider.registerFile(new RegisteredMemoryFile(vscode.Uri.file('/workspace/test.customeditor'), ` Custom Editor!` )) - fileSystemProvider.registerFile(new RegisteredMemoryFile(vscode.Uri.file('/tmp/test.css'), ` + fileSystemProvider.registerFile(new RegisteredMemoryFile(vscode.Uri.file('/workspace/test.css'), ` h1 { color: DeepSkyBlue; }` @@ -173,11 +173,11 @@ h1 { // Use a workspace file to be able to add another folder later (for the "Attach filesystem" button) fileSystemProvider.registerFile(new RegisteredMemoryFile(workspaceFile, JSON.stringify({ folders: [{ - path: '/tmp' + path: '/workspace' }] }, null, 2))) - fileSystemProvider.registerFile(new RegisteredMemoryFile(monaco.Uri.file('/tmp/.vscode/extensions.json'), JSON.stringify({ + fileSystemProvider.registerFile(new RegisteredMemoryFile(monaco.Uri.file('/workspace/.vscode/extensions.json'), JSON.stringify({ recommendations: [ 'vscodevim.vim' ] @@ -246,10 +246,10 @@ export const constructOptions: IWorkbenchConstructionOptions = { editors: useHtmlFileSystemProvider ? undefined : [{ - uri: monaco.Uri.file('/tmp/test.js'), + uri: monaco.Uri.file('/workspace/test.js'), viewColumn: 1 }, { - uri: monaco.Uri.file('/tmp/test.md'), + uri: monaco.Uri.file('/workspace/test.md'), viewColumn: 2 }], layout: useHtmlFileSystemProvider