microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
163.99k stars 29.19k forks source link

Allow a workspace to show individual files from other folders #45177

Open Sneezry opened 6 years ago

Sneezry commented 6 years ago

Update from @bpasero: this issue was renamed based on the discussion at the end (see https://github.com/microsoft/vscode/issues/45177#issuecomment-1341005532 and above)

Original below:

Steps to Reproduce:

N/A

Does this issue occur when all extensions are disabled?: Yes


Currently, .code-workspace only contains folders field which allows to add folders into workspace. I prefer a way to add single files into workspace for the entire project, such as README or something else.

TuxVinyards commented 6 years ago

I seem to be able to add files to the 'workspace' by just using file > open. However, they don't show in the workspace side bar, so can't do things like rename when doing versioning numbers. Also 'gitlens' doesn't seem to track them either.

TuxVinyards commented 6 years ago

Or, to put this in different words:
I can create a workspace from a couple of folders. But if I want to add a couple of files as well, I can't get the same workability The .workspace file seems to record the files that I have open but as they don't show in the side bar ....

OwenPattison commented 6 years ago

I've had the same issue this week where I've altered the structure of my solution so that i only have single package.json and tsconfig.json in the root of my solution, where previously there were multiple of both package.json and tsconfig.json located inside of a corresponding 'App' folder, this meant in my workspace i could add each 'App' folder and vscode would be happy - no errors.

Now that I've changed the structure to have a single package.json and tsconfig.json which handles each app the workspace does not include the files due to them now being located in the root which leads to ts errors in my files.

The only workaround i have currently is to include my entire solution which isn't very desirable.

Having the ability to add individual files to the workspace means i could retain a workspace that only has my desired files in but means i could include the necessary files to not have errors.

qiulang commented 6 years ago

.gitignore, README and docker-compose.yml(my case) are the good examples to be in the root of my app folder. Besides, I feel weird that although I can't add those files to my workspace I can just open a new window to open my app folder. All files inside my app folder will show but I can't debug my app (vscode shows 'no configuration') like when I use workspace.

jalovatt commented 6 years ago

Yes please.

Due to the setup of the repository I'm working in, a particular project might have its own subfolder but also has to have a package file at root-level. Would be great to have the package as part of the workspace.

IvanG96 commented 6 years ago

And i would say even more. Due to the project specific that i'm working on, i have several c# projects in the several folders that included into one visual studio solution. And there are hundreds of xml files in this folders that can't be made as part of solution. So it would be really great and convinient to include all of them into vs code workspace by simple pattern like \xmlfolder**.xml

bpasero commented 6 years ago

I am closing this "as designed". This is not a scenario we will support anytime soon. Please also see https://github.com/Microsoft/vscode/wiki/Issue-Grooming#out-of-scope-feature-requests

jefferysterner commented 6 years ago

It's ridiculous that you aren't doing this. Not doing it defeats most of the purpose of having workspaces.

TuxVinyards commented 6 years ago

@bpasero I have to wonder if the bar isn't being set a bit high. There's an under-diiscussion label for bugs. Maybe the same is required for feature request.

@others since contributing to this thread have wondered at times if it is actually desirable:

  1. I have started using symlinks as a work around, storing the files in the main folder and placing external links to these where needed.

  2. Other IDE's don't have, or may not have this feature. This feature would limit the intersharability of code and makes me wonder about my support for it.

devuxer commented 6 years ago

Looking at the criteria in https://github.com/Microsoft/vscode/wiki/Issue-Grooming#out-of-scope-feature-requests, I'm a little confused why this was closed.

  1. Does the functionality described in the feature request have any reasonable chance to be on the next roadmap?

This doesn't really seem to be a criterion on its own. It's very dependent on (2) and (3).

  1. Are the costs to implement the functionality reasonable given the size of our team? I.e. can we afford the feature?

If allowing some loose files or folders at the same level as project folders has a particular high cost, it would be helpful to get a brief explanation why that is the case. The project folders themselves would seem much more complicated to implement, given all the special UI treatment they get. I would also argue that allowing a .vscode folder for the whole workspace, rather than embedding settings and launch configuration into the code-workspace file and ignoring certain settings set at the project-level that conflict (like zoom), you would end up with a much cleaner, "fully baked" system.

  1. Has the community at large expressed interest in this functionality? I.e. has it gathered more than 10 up-votes or more than 10 comments over the last 6 months? Just for reference, the up-vote criterion alone covers more than 500 feature requests as of right now, September 10th, 2018. We also look at the duplicates for this analysis.

This post has 28 upvotes in the last seven months and this comment will be the 10th.

Would the team consider giving this one more look?

EDIT: better make that 125 votes and counting, as of 11 MAY 2020.

MrRobboto commented 6 years ago

30th Upvote.

I was very glad to start using workspaces, instead of having my entire root folder in VS Code which has word documents and crap. I was able to just have the main folders I code in (Web, API, and DB for this main project I'm on).

I was surprised to find I couldn't add a couple other files to the workspace that would be nice to show up right next to the main folders. Specifically Readmes would be nice and also I like to put the API .sln there so I can quickly go to view it in explorer and open it in VS (I avoid going in there).

Anyway, this seems like it would obviously be on the roadmap to go along with Workspaces as they are. If there's a ton of other backlog more important I'd get a delay but to close this seems wrong.

If a workspace files feature is so far down on the list that it will never get done, then workspace folders should be right there with it and shouldn't have been done. I'm not following the logic that implementing with folders was important enough to do and just stop there...

MrRobboto commented 6 years ago

@TuxVinyards

Thanks for suggesting Symlinks, I ended up going this route as well for a workaround and it's not too bad, basically achieves what I was trying.

I added a "Links" folder to my workspace which just has a list of Symlinks to files I wanted to include in the workspace.

i-am-malaquias commented 5 years ago

There does seem to be interest for this feature. Maybe an easier way to implement this would be the ability to hide files/folders from the workspace structure? I wouldn't mind adding the entire root folder and then choosing what I don't want to see in the explorer, probably. This approach also makes more sense in cases where you create new files in the project, they would automatically show up in the explorer if they're not in an exclusion list, otherwise you would have to manually add new files to the explorer.

MrRobboto commented 5 years ago

@MrGoDuck @TuxVinyards

Yeah, that would work and offers plenty of flexibility - I would absolutely be in favor of that.

PS - My hard links are breaking (not sure which app is overwriting files but it happens - I hope it's not VS Code). So I had to get rid of my "Links" folder. I am back to just searching for the files I'm looking for when I'd ultimately like hard links in the root, included in the workspace.

Ex of the ideal:

API --Models ----Model.cs ----A bunch of other files crowding the space... Web --Models ----App Model.ts --Etc. APIModel.cs (h link included in ws) WebModel.ts (h link included in ws)

A bit unrelated but it seems like VS Code might be the one breaking my hard links...! I had the two links in a "Links" folder included in the workspace and it was working perfectly for a session and then broke. I didn't open the files in any other app.

TuxVinyards commented 5 years ago

@MrGoDuck Sounds like the start of an algorithm. What are you like at Typescript? Might work adding lines to the .jsn. manually ..

Not tried the above. @MrRobboto my symlinks method is still working for me. Maybe VS Code doesn't play nicely with links? I have only 'real' files in the working folder. The outside files as links works but does have limitations. Maybe an OS issue?

Jeffrey-Hall commented 5 years ago

I found it hard to believe I could not add files to my workspace. Please reconsider this feature request.

josiah47 commented 5 years ago

I too found it ridiculous that this was not a feature.

raosatish commented 5 years ago

Yes. Please add the ability to add individual files to the workspace.

safield commented 5 years ago

+1

IvanG96 commented 5 years ago

Please add the ability to add individual files to the workspace by some pattern (e.g. *.txt).

Thank you.

Best regards,

Ivan Grechko

On Wed, Nov 28, 2018 at 11:25 PM +0300, "safield" notifications@github.com wrote:

+1

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

EstevezCarlos commented 5 years ago

+1 MS PLZ

I have a walk around:

1) I add folder that contains files I need. 2) I install Make Hidden extension. 3) I hide files that i do not want to see in my workspace.

i-am-malaquias commented 5 years ago

@EstevezCarlos This should be available without the use of an extension.

EstevezCarlos commented 5 years ago

@MrGoDuck

100% Agree. So I voted +1 for Microsoft to see we need this. But maybe someone will find my tip useful. Peace!

devuxer commented 5 years ago

@bpasero, this has gained a lot of traction since you closed it. Please reopen.

code1line commented 5 years ago

@bpasero Possible use-case: You want to see some temporary files from other directories while working in your project-folder. You can not add the entire Temp-folder because it contains so many files. No feature???

brent-charlton commented 5 years ago

Would also really like this feature!

UmanShahzad commented 5 years ago

This should really be considered - how can this not be useful?

matias-harding commented 5 years ago

+1 Basic functionality enabled in every other ide available.

malefficient commented 5 years ago

Good news! Though undocumented, individual files can be referenced in a workspace. Open your_project.code_workspace as a file. (If confused by this, use something other than VSCode. Notepad, etc.)

Then, create a Folder element that refers to an individual file. I.e. 'Readme_haiku.txt' below.

your_project.vscode_workspace:

  ... 
   "folders": [
            {
                  "path": "Readme_haiku.txt",
                  "name": "!Readme (poem)"
            },
           {
                  "path": "roles/pki.settings",

            },
...
single_file
mationai commented 5 years ago

@malefficient Doesn't work for me.

Got 'spawn ENOTDIR' error. https://github.com/Microsoft/vscode/issues/63226

malefficient commented 5 years ago

Sorry to hear that :\ FWIW I'm running the latest insider version: Version 1.35.0-insider (1.35.0-insider)

IvanG96 commented 5 years ago

Hi @malefficient. Is it possible to add several files in the following way: "path": "*.settings" for the folder element?

Best regards,

Ivan Grechko

On Thu, May 23, 2019 at 9:28 AM +0300, "Johnny C" notifications@github.com wrote:

Sorry to hear that :\ FWIW I'm running the latest insider version:

Version 1.35.0-insider (1.35.0-insider)

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

manivi commented 5 years ago

Good news! Though undocumented, individual files can be referenced in a workspace. Open your_project.code_workspace as a file. (If confused by this, use something other than VSCode. Notepad, etc.)

Then, create a Folder element that refers to an individual file. I.e. 'Readme_haiku.txt' below.

your_project.vscode_workspace:

... 
 "folders": [
          {
                "path": "Readme_haiku.txt",
                "name": "!Readme (poem)"
          },
         {
                "path": "roles/pki.settings",

          },
...
single_file

be warned, this breaks other functionalites like Debug Multiple-function-projects)

dlordi commented 5 years ago

As a devops, I also think it would be very useful to have individual files in the workspace (ie: instead of adding an entire /etc folder, I could be able to add only files I'm interested in for my sysadmin tasks, like my.cnf or samba/smb.conf). Even better: it would be great to organize these files in logical groups (ie: "db" group with my.cnf, "other services" group with samba/smb.conf and cups/printers.conf, etc...)

"fileGroups": [{"name": "db", "files": [{ "name": "mysql config", "path": "/etc/my.cnf" }]}, {"name": "misc", "files": [{ "name": "samba", "path": "/etc/samba/smb.cnf" }]}]

sfsccn commented 5 years ago

The Favorites extension seems to be a decent substitute for this feature. However, I would prefer to simply add files to the workspace as I think this would be very useful.

N7K4 commented 5 years ago

{ "path": "README.md", "name": "MyReadme (on root)" },

@manivi For me it shows the files in VScode but I cannot open the file. It is handled like an empty folder. My vscode version 1.37.1,

nuno-andre commented 5 years ago

I just can't understand this "It's not a bug, it's a feature" attitude.

I usually scaffold related projects in a single metarepo set to track my dev server (so I can upstream-track the children repos) together with folders for integration tests, building tools and artifacts and an ever-increasing number of related files.

One of these files is a .code-workspace which is, as the rest of them, obviously part of the project.

I believe this kind of scaffolding, either gitted or not, is increasingly common. And whatever the argument, or excuse for wontfix, it seems hard to understand why any of them (especially .code-workspace) should remain outside the explorer.

I think this petition has gained significant traction so as to deserve a place in a (albeit distant) milestone.

Meanwhile I'm relying on a nasty hack to overcome this limitation and the jerky globbing of files.exclude in multi-root workspaces:

{
    "folders": [
        {
            "name": ".",
            "path": "."
        },
        {
            "path": "back"
        },
        {
            "name": "data",
            "path": "_data"
        },
        {
            "path": "front"
        }
    ],
    "settings": {
        "files.exclude": {
            "back/": true,
            "_data/": true,
            "front/": true
        }
    }
}

Untitled

I've written a little script which makes the .code-workspace while preventing any project dirname from matching with some inner dirname by prepending it with an underscore. I hope that it may be of some help to somebody.

from pathlib import Path
import json
import os

# not project dirs, they only belong to the metarepo 
metadirs = {'.dev', '.git', 'bin', 'dist', 'docs', 'tests', 'vendor'}
template = {
    'folders': [{'name': '.', 'path': '.'}],
    'settings': {'files.exclude': {}}
}

def make_multiroot_workspace():
    # It's inside './.dev', hence the '..'
    root = Path(__file__).parent.joinpath('..').resolve()
    dirs = [d for d in root.iterdir() if d.is_dir() and d.name not in metadirs]
    for d in dirs:
        walk = os.walk(root)
        next(walk)
        if any(d.name in dirs for _, dirs, _ in walk):
            d.rename(d.with_name(f'_{d.name}'))
            v = {'name': d.name, 'path': f'_{d.name}'}
        else:
            v = {'path': d.name}
        template['folders'].append(v)
        template['settings']['files.exclude'].update({f'{v["path"]}/': True})
    root.joinpath(f'{root.name}.code-workspace').write_text(
        json.dumps(template, indent=4))
dseynhae commented 5 years ago

I am working on projects where there are a few files in a massive build environment that need to be updated in a coordinated fashion. I don't want to add folders, because there are too many files in there that are just completely irrelevant for the particular project (and I don't want to wast time searching them for every search that I launch in my work space). So my projects should be workspaces with nothing but files added to them. And I then I want to context switch from one workspace to another, with only the files associated with that workspace, and not the other files in the same folder as the files I'm working on... Here is to hoping that my comment with the flood of others makes for reconsideration of this feature as a valuable feature that make VSCode the go-to editor for developers...

starship863 commented 5 years ago

It is highly welcome if this functionality could be included.

TuxVinyards commented 5 years ago

There are currently 28 people signed up for notifications on this issue. It continues to stay active despite its status being auto-changed to 'closed' during a mass crud cull this time last year.

Given that the development team have over 5000 open issues at present & that they even have to use a bot to scan those, I find myself struggling to see why they would even continue to look at the 68,000 'closed' issues.

I would like to refer people a thread that currently has an 'open' status. I am wondering if this might be a target for us all to bump up.

@johndog : https://github.com/microsoft/vscode/issues/73511


Also, spotted this seemingly new addition to Code's inner workings:

"the idea of FileType is that I can have FileType.SymbolicLink | FileType.Directory so that I can signal both types right?" https://github.com/microsoft/vscode/issues/71055

Long shot but might this fire up someone enough to create something for a pull request?

Enzo-Migliardi commented 5 years ago

Good idea, a simple functionality like that should have already been implemented

TriMoon commented 4 years ago

@bpasero I am closing this "as designed". This is not a scenario we will support anytime soon. Please also see https://github.com/Microsoft/vscode/wiki/Issue-Grooming#out-of-scope-feature-requests

Please remove the *out-of-scope tag and re-open this issue, look at how many up-votes and comments there are after you stuck this in the trash bin !

A real world example for the need:

I have a project that makes use of an environment file in /etc/default which is sourced from bash scripts in the project. It is not desired to be forced to include the whole /etc/default directory in the project's *.code-workspace file, because it's only a single file that is needed inside that directory.

TuxVinyards commented 4 years ago

Yay.

TriMoon commented 4 years ago

@malefficient Good news! Though undocumented, individual files can be referenced in a workspace. Open your_project.code_workspace as a file. (If confused by this, use something other than VSCode. Notepad, etc.)

Then, create a Folder element that refers to an individual file. I.e. 'Readme_haiku.txt' below.

your_project.vscode_workspace:

... 
 "folders": [
          {
                "path": "Readme_haiku.txt",
                "name": "!Readme (poem)"
          },
         {
                "path": "roles/pki.settings",

          },
...

You saved my day :+1: :1st_place_medal: :clap: I just used the below and works perfectly, used in my project that i am setting up at moment:

{
"folders": [
{
"name": "Defaults",
"path": "/etc/default/arma3ds"
},
...
],
...
}
starship863 commented 4 years ago

It is really great that this issue is reopened. Hope this functionality could be officially supported soon.

TriMoon commented 4 years ago

Regarding my last reply: Correction i had to revert to using the whole directory, because VSC would lockup trying to fill my tasklist in Task Explorer after restarting the editor :angry:

lloydsargent42 commented 4 years ago

I'm currently working with a SDK that requires the compilation of source files in the SDK (for a microcontroller so they don't put everything in the library). We literally can NOT move to VSCode for this very reason (well, we could, but would have to replicate what is already in VSCode -- might as well use Sublime).

We really need the individual file feature. I want to get our teams all on VSCode.

I'm sure just folders is great for MS, but for real-world programming, it kinda isn't.

PS I can easily do this in Xcode (have been doing it for years). Why is this so darn difficult for VSCode?

charmsRace commented 4 years ago

Another common use case: having a simple workspace to manage personal config files like ~/.bashrc, ~/.gitconfig, ~/.vimrc, &c., without opening one's entire home directory.

Is this the sort of thing that would be open for user contribution? (Not that it's like I'd have time in the near future, but prima facie it doesn't seem like it'd be a large delta.)

stuartthomson commented 4 years ago

Our repo has several components in it, each with subdirectories and files (such as Dockerfile, docker-compose) at the root level. To make a workspace for an individual component I cannot directly include the single files, instead I have to exclude all the others. This is time consuming and the workspaces tend to become out of date. When you add a file to root level you have to exclude it from all of the workspaces.

Would love to see this addressed.

Merott commented 4 years ago

My workaround right now is to add the top-level folder itself to the folders list in .code-workspace.

{
  "folders": [
    {
      "path": "projects/frontend",
      "name": "frontend"
    },
    {
      "path": "projects/backend",
      "name": "backend"
    },
    {
      "path": ".", //  <---------------------- THIS
      "name": ".workspace"
    },
  ],
  "settings": {
    "files.exclude": {
      "**/node_modules": true,
    }
  }
}

You could add the projects folder to the files.exclude list, but I found that to be unnecessary.

Hoping that helps someone!