From 3025d1f01b5b7725e7c1c213d63f3de45f0534b3 Mon Sep 17 00:00:00 2001 From: Damjan Cvetko Date: Tue, 7 Nov 2023 15:34:38 +0100 Subject: [PATCH] feat: Add limited support for virtual workspaces (#930) * Add limited support for virtual workspaces. Override ${workspaceFolder} variable substitution. * Do not show run/debug menu icon when on virtual FS. Change deprecated ${workspaceRoot} default. * Prepare replace for currently un-mapped configuration variables. * CHANGELOG --- CHANGELOG.md | 4 ++++ package.json | 14 +++++++++----- src/extension.ts | 23 +++++++++++++++++++++++ 3 files changed, 36 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f583d552..ba4da25f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## [1.34.0] + +- Partial support for virtual workspaces + ## [1.33.1] - Fix editor title run/debug button. diff --git a/package.json b/package.json index b310af01..8e59a561 100644 --- a/package.json +++ b/package.json @@ -165,6 +165,10 @@ "restrictedConfigurations": [ "php.debug.executablePath" ] + }, + "virtualWorkspaces": { + "supported": "limited", + "description": "In virtual workspaces, PHP process cannot be started, but can listen for incoming connections." } }, "contributes": { @@ -211,7 +215,7 @@ "cwd": { "type": "string", "description": "Absolute path to the working directory of the program being debugged. Default is the current workspace.", - "default": "${workspaceRoot}" + "default": "${workspaceFolder}" }, "runtimeExecutable": { "type": "string", @@ -527,23 +531,23 @@ "editor/title/run": [ { "command": "extension.php-debug.runEditorContents", - "when": "resourceLangId == php && !inDiffEditor", + "when": "resourceLangId == php && !inDiffEditor && resourceScheme == file", "group": "navigation@1" }, { "command": "extension.php-debug.debugEditorContents", - "when": "resourceLangId == php && !inDiffEditor", + "when": "resourceLangId == php && !inDiffEditor && resourceScheme == file", "group": "navigation@2" } ], "commandPalette": [ { "command": "extension.php-debug.debugEditorContents", - "when": "resourceLangId == php && !inDiffEditor" + "when": "resourceLangId == php && !inDiffEditor && resourceScheme == file" }, { "command": "extension.php-debug.runEditorContents", - "when": "resourceLangId == php && !inDiffEditor" + "when": "resourceLangId == php && !inDiffEditor && resourceScheme == file" } ] }, diff --git a/src/extension.ts b/src/extension.ts index d417ba4c..a5347a7b 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -71,6 +71,29 @@ export function activate(context: vscode.ExtensionContext) { } } } + if (folder && folder.uri.scheme !== 'file') { + // replace + if (debugConfiguration.pathMappings) { + for (const key in debugConfiguration.pathMappings) { + debugConfiguration.pathMappings[key] = debugConfiguration.pathMappings[key].replace( + '${workspaceFolder}', + folder.uri.toString() + ) + } + } + // The following path are currently NOT mapped + /* + debugConfiguration.skipEntryPaths = debugConfiguration.skipEntryPaths?.map(v => + v.replace('${workspaceFolder}', folder.uri.toString()) + ) + debugConfiguration.skipFiles = debugConfiguration.skipFiles?.map(v => + v.replace('${workspaceFolder}', folder.uri.toString()) + ) + debugConfiguration.ignore = debugConfiguration.ignore?.map(v => + v.replace('${workspaceFolder}', folder.uri.toString()) + ) + */ + } return debugConfiguration }, })