{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/vscode/issues/45399","repository_url":"https://api.github.com/repos/Microsoft/vscode","labels_url":"https://api.github.com/repos/Microsoft/vscode/issues/45399/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/vscode/issues/45399/comments","events_url":"https://api.github.com/repos/Microsoft/vscode/issues/45399/events","html_url":"https://github.com/Microsoft/vscode/issues/45399","id":303806530,"number":45399,"title":"Support \"workspace folders\" that are sub-folders of an existing open folder","user":{"login":"DanTup","id":1078012,"avatar_url":"https://avatars2.githubusercontent.com/u/1078012?v=4","gravatar_id":"","url":"https://api.github.com/users/DanTup","html_url":"https://github.com/DanTup","followers_url":"https://api.github.com/users/DanTup/followers","following_url":"https://api.github.com/users/DanTup/following{/other_user}","gists_url":"https://api.github.com/users/DanTup/gists{/gist_id}","starred_url":"https://api.github.com/users/DanTup/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DanTup/subscriptions","organizations_url":"https://api.github.com/users/DanTup/orgs","repos_url":"https://api.github.com/users/DanTup/repos","events_url":"https://api.github.com/users/DanTup/events{/privacy}","received_events_url":"https://api.github.com/users/DanTup/received_events","type":"User","site_admin":false},"labels":[{"id":272689392,"url":"https://api.github.com/repos/Microsoft/vscode/labels/feature-request","name":"feature-request","color":"dcdcdc","default":false},{"id":535120898,"url":"https://api.github.com/repos/Microsoft/vscode/labels/multi-root","name":"multi-root","color":"c5def5","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":10,"created_at":"2018-03-09T11:12:18Z","updated_at":"2018-03-09T17:41:43Z","closed_at":null,"author_association":"NONE","body":"```text\r\nmy_repo_folder/   <-- WorkspaceFolder\r\n  |- bin/\r\n      |- ...\r\n  |- docs/\r\n      |- ...\r\n  |- examples/\r\n      |- example_app_1/   <-- WorkspaceFolder\r\n        |- .vscode/\r\n        |- ...\r\n      |- example_app_2/   <-- WorkspaceFolder\r\n        |- .vscode/\r\n        |- ...\r\n  |- lib/\r\n      |- ...\r\n  |- tools/\r\n      |- ...\r\n  |- pubspec.yaml\r\n  |- readme\r\n```\r\n\r\nMultiple projects open in Code has been an ongoing problem for Dart Code users. Users want to be able to open a folder that contains projects (eg. Flutter mobile apps) in sub-folders (or even example projects as sub-folders) however there are a bunch of complications, such as:\r\n\r\n1. Detection of which folders are \"projects\" means walking the whole tree detecting them (eg. which are projects, and of those which are Dart command line and which are Flutter) and it's incredibly complicated to then detect changes in them (I've recently had a go at doing this, but I was basically re-implementing multi-root workspaces in my own way, and it was still flawed in a few ways)\r\n2. launch.json/settings.json cannot be set for each \"project\"\r\n3. Debugger launching is complicated (we have the wrong root, [can't detect which debugger entry point](https://github.com/Microsoft/vscode/issues/45220))\r\n\r\nI tried to avoid fixing this for a long time telling my users to wait for and use multi-root workspaces when they arrive, however they're not very happy with this for a few reasons:\r\n\r\n1. It's clumsy to set up (they have to File -> Add Folder to Workspace for each folder - even though it's already in their explorer tree)\r\n2. It pulls those folders up to the top level so it's not the folder structure on disk/in source control that they're used to\r\n3. Those folders and files now exist multiple times in the explorer (which is both pointless and confusing)\r\n4. I don't well-believe it's defined which WorkspaceFolder we would get for a resource using `getWorkspaceFolder` if it exists in multiple roots\r\n\r\nI've been trying to work around this and raised a couple of requests to try and handle this better (for #43902 and #45220, neither of which would be needed with this feature) but I think a better option is to support marking folders within a tree as workspace folders.\r\n\r\nHere's how I think it could work:\r\n\r\n- A new context menu entry on folders in explorer - `Mark folder as Workspace Folder`\r\n  This treats a folder as if it was added as a workspace folder but *does not* duplicate it at the root in the tree. It gets a slightly different icon to show it's a workspace folder (I think \"project\" is a better name, but I think Workspace folder is already somewhat stuck). This will fire `onDidChangeWorkspaceFolders` when the user sets/unsets it\r\n- Extensions can easily mark folders as workspace folders during activation (eg. they can find `package.json`/`pubspec.yaml`/`app.config`) - this should not cause a \"dirty\" workspace - it should quietly write into the workspace file (or settings file if only a single folder is open)\r\n- VS Code automatically marks any folder that contains a `.vscode` sub-folders as a WorkspaceFolder when opening a folder/workspace\r\n- These folders are treated as any other WorkspaceFolder - they appear in `workspaceFolders`, appear in the debug config drop-downs, are returned from `getWorkspaceFolder`, can have their own `.vscode` folder with settings and launch configs (and getting resource-level settings will cascade up the tree)\r\n\r\nI think this would be a great change for code even outside of Dart/Flutter. It's really natural to have a repository with multiple \"projects\" in it and it's most natural to open the root. As far as I can tell there is nothing inherent in the WorkspaceFolder APIs that say they cannot appear within a tree, so I don't think is a big breaking change."},"comment":{"url":"https://api.github.com/repos/Microsoft/vscode/issues/comments/371886850","html_url":"https://github.com/Microsoft/vscode/issues/45399#issuecomment-371886850","issue_url":"https://api.github.com/repos/Microsoft/vscode/issues/45399","id":371886850,"user":{"login":"bpasero","id":900690,"avatar_url":"https://avatars3.githubusercontent.com/u/900690?v=4","gravatar_id":"","url":"https://api.github.com/users/bpasero","html_url":"https://github.com/bpasero","followers_url":"https://api.github.com/users/bpasero/followers","following_url":"https://api.github.com/users/bpasero/following{/other_user}","gists_url":"https://api.github.com/users/bpasero/gists{/gist_id}","starred_url":"https://api.github.com/users/bpasero/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bpasero/subscriptions","organizations_url":"https://api.github.com/users/bpasero/orgs","repos_url":"https://api.github.com/users/bpasero/repos","events_url":"https://api.github.com/users/bpasero/events{/privacy}","received_events_url":"https://api.github.com/users/bpasero/received_events","type":"User","site_admin":false},"created_at":"2018-03-09T17:41:43Z","updated_at":"2018-03-09T17:41:43Z","author_association":"MEMBER","body":"> Yeah, and would only work the opposite way to the user wants (keeps the top-levels, hides the children)?\r\n\r\nI am not sure I get that, but the real issue is that this setting is stored inside the folder but it only makes sense outside the folder (when opened as part of that workspace), so not a very good solution...\r\n\r\n> Ah, that's good to know. Someone told me something didn't work that I assumed was because this was returning the wrong thing - I'll dig into it and raise a bug if it seems to do the wrong thing anywhere.\r\n\r\nI assume you refer to this method: https://github.com/Microsoft/vscode/blob/master/src/vs/vscode.d.ts#L5444. We might need to tweak the JSDoc to clarify this and/or fix bugs if there are any.\r\n\r\n> Yeah, in this case I really want it to be transparent to the user. The user just wants to open a repo and have us do the right thing. Currently users keep asking why they can't debug their project in a sub-folder and it sounds kind ridiculous that I can't fix it (it needs #45220 - probably it didn't before I merged my debug types, but that was done for other good reasons).\r\n\r\nHave you thought about just checking in a `code-workspace` file into that repo that uses relative paths and is ready to go? Then tell users to just open that workspace file?\r\n\r\n> Ah cool, didn't realise I could remove and add the same folders in one operation. Will this cause a reload, or can it be done sneakily without prompting the user or affecting open files/etc.?\r\n\r\nIt will only cause a reload if the first folder changes or if you transition from 0/1-folder into a workspace, but that is independent from that method, that is just the way how we support backwards compatibility. The method will do a diff of the folders that changed and then do the minimal update and the minimal set of events."}}
{"actor":{"display_login":"bpasero"}}