diff --git a/package-lock.json b/package-lock.json index ff6a19e..5fb0742 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,7 +19,7 @@ "@typescript-eslint/eslint-plugin": "^6.0.0", "@typescript-eslint/parser": "^6.0.0", "@vscode/test-electron": "^2.3.4", - "@vscode/vsce": "^3.0.0", + "@vscode/vsce": "^3.2.1", "esbuild": "0.19.8", "esbuild-plugin-eslint": "^0.3.7", "esbuild-visualizer": "^0.4.1", @@ -1202,9 +1202,9 @@ } }, "node_modules/@vscode/vsce": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/@vscode/vsce/-/vsce-3.0.0.tgz", - "integrity": "sha512-UKYcC7fcSw6AUK6nlfm8A8WSOA41H3DRAwafCMp9CQpg3K9COAQKkrgQ+dKPhwkFTP7SPZNEiulDpPLwvr5QQQ==", + "version": "3.2.1", + "resolved": "https://nexus-proxy.repo.local.sfdc.net/nexus/content/groups/npm-all/@vscode/vsce/-/vsce-3.2.1.tgz", + "integrity": "sha512-AY9vBjwExakK1c0cI/3NN2Ey0EgiKLBye/fxl/ue+o4q6RZ7N+xzd1jAD6eI6eBeMVANi617+V2rxIAkDPco2Q==", "dev": true, "license": "MIT", "dependencies": { @@ -1220,7 +1220,7 @@ "hosted-git-info": "^4.0.2", "jsonc-parser": "^3.2.0", "leven": "^3.1.0", - "markdown-it": "^12.3.2", + "markdown-it": "^14.1.0", "mime": "^1.3.4", "minimatch": "^3.0.3", "parse-semver": "^1.1.1", @@ -5589,12 +5589,13 @@ } }, "node_modules/linkify-it": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-3.0.3.tgz", - "integrity": "sha512-ynTsyrFSdE5oZ/O9GEf00kPngmOfVwazR5GKDq6EYfhlpFug3J2zybX56a2PRRpc9P+FuSoGNAwjlbDs9jJBPQ==", + "version": "5.0.0", + "resolved": "https://nexus-proxy.repo.local.sfdc.net/nexus/content/groups/npm-all/linkify-it/-/linkify-it-5.0.0.tgz", + "integrity": "sha512-5aHCbzQRADcdP+ATqnDuhhJ/MRIqDkZX5pyjFHRRysS8vZ5AbqGEoFIb6pYHPZ+L/OC2Lc+xT8uHVVR5CAK/wQ==", "dev": true, + "license": "MIT", "dependencies": { - "uc.micro": "^1.0.1" + "uc.micro": "^2.0.0" } }, "node_modules/load-json-file": { @@ -5939,35 +5940,29 @@ } }, "node_modules/markdown-it": { - "version": "12.3.2", - "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-12.3.2.tgz", - "integrity": "sha512-TchMembfxfNVpHkbtriWltGWc+m3xszaRD0CZup7GFFhzIgQqxIfn3eGj1yZpfuflzPvfkt611B2Q/Bsk1YnGg==", + "version": "14.1.0", + "resolved": "https://nexus-proxy.repo.local.sfdc.net/nexus/content/groups/npm-all/markdown-it/-/markdown-it-14.1.0.tgz", + "integrity": "sha512-a54IwgWPaeBCAAsv13YgmALOF1elABB08FxO9i+r4VFk5Vl4pKokRPeX8u5TCgSsPi6ec1otfLjdOpVcgbpshg==", "dev": true, + "license": "MIT", "dependencies": { "argparse": "^2.0.1", - "entities": "~2.1.0", - "linkify-it": "^3.0.1", - "mdurl": "^1.0.1", - "uc.micro": "^1.0.5" + "entities": "^4.4.0", + "linkify-it": "^5.0.0", + "mdurl": "^2.0.0", + "punycode.js": "^2.3.1", + "uc.micro": "^2.1.0" }, "bin": { - "markdown-it": "bin/markdown-it.js" - } - }, - "node_modules/markdown-it/node_modules/entities": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/entities/-/entities-2.1.0.tgz", - "integrity": "sha512-hCx1oky9PFrJ611mf0ifBLBRW8lUUVRlFolb5gWRfIELabBlbp9xZvrqZLZAs+NxFnbfQoeGd8wDkygjg7U85w==", - "dev": true, - "funding": { - "url": "https://github.com/fb55/entities?sponsor=1" + "markdown-it": "bin/markdown-it.mjs" } }, "node_modules/mdurl": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/mdurl/-/mdurl-1.0.1.tgz", - "integrity": "sha512-/sKlQJCBYVY9Ers9hqzKou4H6V5UWc/M59TH2dvkt+84itfnq7uFOMLpOiOS4ujvHP4etln18fmIxA5R5fll0g==", - "dev": true + "version": "2.0.0", + "resolved": "https://nexus-proxy.repo.local.sfdc.net/nexus/content/groups/npm-all/mdurl/-/mdurl-2.0.0.tgz", + "integrity": "sha512-Lf+9+2r+Tdp5wXDXC4PcIBjTDtq4UKjCPMQhKIuzpJNW0b96kVqSwW0bT7FhRSfmAiFYgP+SCRvdrDozfh0U5w==", + "dev": true, + "license": "MIT" }, "node_modules/memorystream": { "version": "0.3.1", @@ -7171,6 +7166,16 @@ "node": ">=6" } }, + "node_modules/punycode.js": { + "version": "2.3.1", + "resolved": "https://nexus-proxy.repo.local.sfdc.net/nexus/content/groups/npm-all/punycode.js/-/punycode.js-2.3.1.tgz", + "integrity": "sha512-uxFIHU0YlHYhDQtV4R9J6a52SLx28BCjT+4ieh7IGbgwVJWO+km431c4yRlREUAsAmt/uMjQUyQHNEPf0M39CA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, "node_modules/qs": { "version": "6.5.3", "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.3.tgz", @@ -8991,10 +8996,11 @@ } }, "node_modules/uc.micro": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-1.0.6.tgz", - "integrity": "sha512-8Y75pvTYkLJW2hWQHXxoqRgV7qb9B+9vFEtidML+7koHUFapnVJAZ6cKs+Qjz5Aw3aZWHMC6u0wJE3At+nSGwA==", - "dev": true + "version": "2.1.0", + "resolved": "https://nexus-proxy.repo.local.sfdc.net/nexus/content/groups/npm-all/uc.micro/-/uc.micro-2.1.0.tgz", + "integrity": "sha512-ARDJmphmdvUk6Glw7y9DQ2bFkKBHwQHLi2lsaH6PPmz/Ka9sFOBsBluozhDltWmnv9u/cF6Rt87znRTPV+yp/A==", + "dev": true, + "license": "MIT" }, "node_modules/unbox-primitive": { "version": "1.0.2", diff --git a/package.json b/package.json index afc4800..978e6d9 100644 --- a/package.json +++ b/package.json @@ -232,11 +232,6 @@ { "id": "bazelTaskOutline", "name": "Bazel Run Targets" - }, - { - "id": "rootFileViewer", - "name": "Project Root (Files)", - "when": "isMultiRoot" } ] }, @@ -333,7 +328,7 @@ "@typescript-eslint/eslint-plugin": "^6.0.0", "@typescript-eslint/parser": "^6.0.0", "@vscode/test-electron": "^2.3.4", - "@vscode/vsce": "^3.0.0", + "@vscode/vsce": "^3.2.1", "esbuild": "0.19.8", "esbuild-plugin-eslint": "^0.3.7", "esbuild-visualizer": "^0.4.1", diff --git a/src/extension.ts b/src/extension.ts index 611d09f..d341f9d 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -21,7 +21,6 @@ import { registerLSClient } from './loggingTCPServer'; import { ProjectViewManager } from './projectViewManager'; import { BazelRunTargetProvider } from './provider/bazelRunTargetProvider'; import { BazelTaskProvider } from './provider/bazelTaskProvider'; -import { RootFileViewProvider } from './provider/rootFileViewProvider'; import { getWorkspaceRoot, initBazelProjectFile, @@ -46,10 +45,6 @@ export async function activate(context: ExtensionContext) { BazelRunTargetProvider.instance ); tasks.registerTaskProvider('bazel', new BazelTaskProvider()); - window.registerTreeDataProvider( - 'rootFileViewer', - RootFileViewProvider.instance - ); BazelLanguageServerTerminal.trace('extension activated'); diff --git a/src/projectViewManager.ts b/src/projectViewManager.ts index d655131..65c64cb 100644 --- a/src/projectViewManager.ts +++ b/src/projectViewManager.ts @@ -41,14 +41,19 @@ export namespace ProjectViewManager { extensions: await getVscodeConfig('extensions'), }; writeFileSync( - `${workspaceRoot}/${workspaceRootName}.code-workspace`, + `${workspaceRoot}/workspace.code-workspace`, Buffer.from(JSON.stringify(workspaceFile, null, 2)) ); + // cleanup all old single root workspace files + await workspace.fs.delete(Uri.file(`${workspaceRoot}/.vscode`), { + recursive: true, + }); + // reload the window using the new workspace commands.executeCommand( 'vscode.openFolder', - Uri.file(`${workspaceRoot}/${workspaceRootName}.code-workspace`) + Uri.file(`${workspaceRoot}/workspace.code-workspace`) ); } return; @@ -77,6 +82,9 @@ export namespace ProjectViewManager { async function getDisplayFolders(): Promise { let displayFolders = new Set(['.eclipse']); // TODO bubble this out to a setting + if (isMultiRoot()) { + displayFolders.add('.'); + } try { const bazelProjectFile = await getBazelProjectFile(); if (bazelProjectFile.directories.includes('.')) { @@ -164,11 +172,11 @@ export namespace ProjectViewManager { k.includes('.eclipse') ).length; - const viewAll = displayFolders.includes('.'); + const viewAll = displayFolders.includes('.') && !isMultiRoot(); const fileWatcherExcludePattern = viewAll ? '' - : `**/!(${Array.from(displayFolders.sort()).join('|')})/**`; + : `**/!(${Array.from(displayFolders.filter((s) => s !== '.').sort()).join('|')})/**`; if (viewAll) { // if viewAll and existing config doesn't contain .eclipse return diff --git a/src/provider/rootFileViewProvider.ts b/src/provider/rootFileViewProvider.ts deleted file mode 100644 index 7ae8d90..0000000 --- a/src/provider/rootFileViewProvider.ts +++ /dev/null @@ -1,76 +0,0 @@ -import path from 'path'; -import { - Event, - EventEmitter, - FileSystemWatcher, - ProviderResult, - RelativePattern, - ThemeIcon, - TreeDataProvider, - TreeItem, - TreeItemCollapsibleState, - Uri, - workspace, -} from 'vscode'; -import { getWorkspaceRoot } from '../util'; - -const WORKSPACE_ROOT = getWorkspaceRoot(); - -export class RootFileViewProvider implements TreeDataProvider { - private static _instance: RootFileViewProvider; - - private _filesWatcher: FileSystemWatcher; - private _onDidChangeTreeData: EventEmitter = - new EventEmitter(); - readonly onDidChangeTreeData: Event = - this._onDidChangeTreeData.event; - - private constructor() { - this._filesWatcher = workspace.createFileSystemWatcher( - new RelativePattern(WORKSPACE_ROOT, '*') - ); - this._filesWatcher.onDidChange((f) => this._onDidChangeTreeData.fire()); - this._filesWatcher.onDidCreate((f) => this._onDidChangeTreeData.fire()); - this._filesWatcher.onDidDelete((f) => this._onDidChangeTreeData.fire()); - } - - public static get instance(): RootFileViewProvider { - if (!this._instance) { - this._instance = new RootFileViewProvider(); - } - return this._instance; - } - - getTreeItem(element: string): TreeItem | Thenable { - return new FileItem(element); - } - getChildren(element?: string | undefined): ProviderResult { - if (!element) { - return workspace.fs - .readDirectory(Uri.file(WORKSPACE_ROOT)) - .then((val) => { - return val.filter((v) => v[1] === 1).map((v) => v[0]); - }); - } - return []; - } -} - -class FileItem extends TreeItem { - constructor(fileName: string, collapsibleState?: TreeItemCollapsibleState) { - super(fileName, collapsibleState); - this.command = { - title: fileName, - command: 'vscode.open', - arguments: [Uri.file(`${WORKSPACE_ROOT}${path.sep}${fileName}`)], - }; - switch (fileName.split('.').reverse()[0]) { - case 'json': - this.iconPath = new ThemeIcon('json'); - break; - default: - this.iconPath = new ThemeIcon('file'); - break; - } - } -}