salesforcedx-vscode icon indicating copy to clipboard operation
salesforcedx-vscode copied to clipboard

Support workspaces

Open torynet opened this issue 6 years ago • 6 comments

Is your feature request related to a problem? Please describe. We have been encouraged to break our solutions up into smaller more focused packages. Having done so, I've started working in vscode with some various package directories added to a vscode workspace. It's just easier than having a bunch of different windows. Unfortunately, this completely breaks the sfdx extensions. The extensions won't run most commands because they don't know what project they are working with.

Describe the solution you'd like It would be good if the extensions could recognize that multiple projects are open in the workspace and determine context based on file location for file specific actions or allow the user to choose a project otherwise.

Describe alternatives you've considered The cli still works wonderfully as you can just cd in the terminal or have more than one terminal. I've just been using that, but it's difficult with things like test runs. The command palette and inline "buttons" are much nicer. Thus far, I have been opening the folder in a new window when I want to run tests.

Additional context The vscode extensions and sfdx in general are awesome. Thank you and keep up the good work.

torynet avatar Sep 14 '18 15:09 torynet

With the advent of "Develop Against Any Org in Visual Studio Code", I think it is more useful as well to provide workspace access to multiple projects connected to different instances. In Eclipse based force.com IDE, it was easy to create multiple projects and use them from a single IDE.

Currently, I open multiple instances of vscode to access multiple projects. Hope this is going to change soon to a single instance of vscode.

venkatpolisetti avatar Oct 19 '18 21:10 venkatpolisetti

Please support this feature asap. This is must for all developers

chandra2ravi avatar Jan 09 '19 16:01 chandra2ravi

Any update on this? (Tentative) roadmap?

admin-nimba avatar Apr 10 '20 19:04 admin-nimba

VSCode has stable multi-root workspaces available. With 1GP to 2GP conversion path in beta, we absolutely need this:

https://code.visualstudio.com/docs/editor/multi-root-workspaces

https://github.com/microsoft/vscode/wiki/Adopting-Multi-Root-Workspace-APIs

https://code.visualstudio.com/updates/v1_47#_single-view

vinodr avatar Jul 16 '20 19:07 vinodr

I ran into that functionality missing today. I have 3 repositories closely tied to each other but need to separate concerns. For active development and deployment this is wasting a huge amount of time. So, I was kind of astonished, that the SDFX extension isn't capable of handling this correctly

Checks on the extension confirmed it's straight going to the first folder in the workspace only. I am surely not an expert in VSCode Extensions. However, I enriched the code a bit:

function getRootWorkspace() {
	// Custom Code Start
	if (vscode_1.workspace.workspaceFolders.length && vscode_1.workspace.workspaceFolders.length !== 1) {
		const currentlyOpenTabfilePath = vscode_1.window.activeTextEditor.document.fileName || {};
		for (let folder of vscode_1.workspace.workspaceFolders){
			if (currentlyOpenTabfilePath.startsWith(folder.uri.fsPath)) {
				return folder;
			}
		}
	}
	// Custom Code Start
	return hasRootWorkspace()
		? vscode_1.workspace.workspaceFolders[0]
		: {};
}

Explanation

The addition is only run if multiple folders exist. In that case, it checks the active editor tab and validates the path of that file against the existingWorkspaceRoots. If any is matched it is straight returned for further processing. If there is only one folder or the logic can't find any match, defaulting to the existing logic to avoid breaking anything.

Advantage

Multiple Workspace Folders seem to work with context menu commands (like Retrieve, Deploy) on the editor window. Nothing in terms of running commands from CLI seems broken in an initial check. And even the explorer context menu works, if a file of the corresponding tree is included.

Drawback

If the active editor window is from another workspace folder than selected in the explorer context, we still face an issue. However, opening any file from that tree (e.g. the one to retrieve/deploy) resolves that issue. Not great but better than nothing.

The above code resides in the core\out}src\util\rootWorkspace.js. In case someone wants to double check, improve and finally contribute back to the repository. Or any maintainer sees options to implement that on a timely manner with proper testing of all functionality. Seems like it's been open a while at least.

SteffenBaumann avatar Jan 13 '22 17:01 SteffenBaumann

I would LOVE to see support for multi-root workspaces. My use-case is that I work on a backend project, front-end project and a Salesforce managed package project.

I tried to add the Salesforce project to the workspace, but commands didn't work and rogue .sfdx folders were added to my other workspaces which I had to constantly delete since the other projects don't have this folder in their gitignore.

Also, I find that the sfdx plugin randomly adds .sdfx folders to my non-salesforce single-root workspaces sometimes and I always end up disabling the extension for specific projects. Unfortunately I don't have more details on this as it only happens intermittently so I am unsure what factors may exist to cause this.

paustint avatar Sep 02 '22 14:09 paustint