Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use workspace file when opening repository in VS Code #7007

Open
ghost opened this issue Mar 4, 2019 · 10 comments
Open

Use workspace file when opening repository in VS Code #7007

ghost opened this issue Mar 4, 2019 · 10 comments
Labels
help wanted Issues marked as ideal for external contributors integrations Issues related to editor and shell integrations that ship in Desktop
Projects

Comments

@ghost
Copy link

ghost commented Mar 4, 2019

Problem
When I open a repo in Github Desktop the app suggests to open the repo in Visual Studio Code. That's great, but instead of opening the root folder I would like it to open .code (workspace) file when it is available in the root. Either per default or via a setting.

Thanks for a great product!

@shiftkey shiftkey added the infrastructure Issues and pull requests related to scripts and tooling for GitHub Desktop label Mar 4, 2019
@shiftkey
Copy link
Member

shiftkey commented Mar 4, 2019

@SimonKibsgaard thanks for the feedback!

Do you have any links to resources explaining this file in more detail?

@shiftkey shiftkey added more-info-needed The submitter needs to provide more information about the issue integrations Issues related to editor and shell integrations that ship in Desktop and removed infrastructure Issues and pull requests related to scripts and tooling for GitHub Desktop labels Mar 4, 2019
@ghost
Copy link
Author

ghost commented Mar 4, 2019

@shiftkey yes, sorry I forgot that.

I believe this is the best source: https://code.visualstudio.com/docs/editor/multi-root-workspaces#_workspace-file

To add some more detail, when I launch the repo from the current button in GitHub Desktop, the repo folder opens and VS Code prompts me to open the workspace instead (because it detects the .code file).

If GitHub Desktop launched the .code file instead of the root folder it would work as I hope for.

Br, Simon

@ghost ghost closed this as completed Mar 4, 2019
@ghost ghost reopened this Mar 4, 2019
@shiftkey shiftkey added help wanted Issues marked as ideal for external contributors and removed more-info-needed The submitter needs to provide more information about the issue labels Mar 4, 2019
@shiftkey
Copy link
Member

shiftkey commented Mar 4, 2019

@SimonKibsgaard thanks for the extra information!

For the moment I'm going to mark this as help wanted as this is a great chance for someone who knows VSCode and workspaces to look into trying to add support for this.

The current launch function for opening an editor isn't aware of editor-specific rules, so I suspect that area will need some enhancement:

/**
* Open a given file or folder in the desired external editor.
*
* @param fullPath A folder or file path to pass as an argument when launching the editor.
* @param editor The external editor to launch.
*/
export async function launchExternalEditor(
fullPath: string,
editor: FoundEditor
): Promise<void> {

@iAmWillShepherd iAmWillShepherd added this to Available in Community via automation Mar 8, 2019
@roottool
Copy link
Contributor

roottool commented Apr 28, 2019

I think that this issue needs to be considered about a pattern that .code-workspace file exists more than one in the root.

I have an one question.
Does Github Desktop the app open all .code-workspace file?

@shiftkey
Copy link
Member

Does Github Desktop the app open all .code-workspace file?

Not currently

@samundra
Copy link
Contributor

samundra commented Dec 15, 2019

Hi @shiftkey

I was exploring code for this feature and able to get this working if we use file with code-workspace in fullPath

export async function launchExternalEditor(
  fullPath: string,
  editor: FoundEditor
): Promise<void> {
  ...
  ...
  if (editor.editor === 'Visual Studio Code') {
    readdir(fullPath, (err, files) => {
      if (err) {
        return console.log('Unable to scan directory: ' + err)
      }
      files.forEach(f => {
        if (f.endsWith('code-workspace')) {
          fullPath = Path.join(fullPath, f)
        }
      })
    })
  }

Current problem, I have is fullPath doesn't seem to change after readdir has finished doing it's job. How can I get that fullPath outside of callback so that it can be used in

if (editor.usesShell) {
    spawn(`"${editorPath}"`, [`"${fullPath}"`], { shell: true })
  } else {
    spawn(editorPath, [fullPath])
  }

@Soitora
Copy link

Soitora commented Feb 17, 2020

How's this come along?

@curtcurt871
Copy link

@roottool roottool removed their assignment Sep 3, 2021
@Lol702702
Copy link

Problem When I open a repo in Github Desktop the app suggests to open the repo in Visual Studio Code. That's great, but instead of opening the root folder I would like it to open .code (workspace) file when it is available in the root. Either per default or via a setting.

Thanks for a great product!

@silopolis
Copy link

For those desperately hoping for this to be implemented, I found myself an alternative solution, using the wottpal/vscode-auto-open-workspace extension.
It actually starts by launching VSCode and immediately reloads the workspace, but that does the trick :)
See settings for other possible behaviors.

PS: There is also haifengkao/AlwaysOpenWorkspace which I haven't tested…

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Issues marked as ideal for external contributors integrations Issues related to editor and shell integrations that ship in Desktop
Projects
Community
In progress
Development

Successfully merging a pull request may close this issue.

8 participants
@shiftkey @silopolis @samundra @Soitora @roottool @curtcurt871 @Lol702702 and others