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

Multi-workspace doesn't display correct python interpreter if a file that's open is different from the root #6282

Closed
rchiodo opened this issue Jun 21, 2019 · 2 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug

Comments

@rchiodo
Copy link

rchiodo commented Jun 21, 2019

Steps to reproduce:

  1. Open multi workspace
  2. Open two files from two different folders
  3. Set python interpreter to be different for each
  4. Close workspace
  5. Reopen

One of the files will show the wrong interpreter (might have to switch which one is active by default to get it to repro)

@rchiodo rchiodo added the bug Issue identified by VS Code Team member as probable bug label Jun 21, 2019
@ghost ghost added the triage-needed Needs assignment to the proper sub-team label Jun 21, 2019
@ghost ghost removed the triage-needed Needs assignment to the proper sub-team label Jun 24, 2019
@karrtikr
Copy link

karrtikr commented Jun 28, 2019

Bug is in line 158 of extension.ts .

    interpreterManager.refresh(workspaceService.hasWorkspaceFolders ? workspaceService.workspaceFolders![0].uri : undefined)
        .catch(ex => console.error('Python Extension: interpreterManager.refresh', ex));

When the workspace is reopened, the extension is told to always use the first workspace folder workspaceService.workspaceFolders![0].uri to refresh interpreters instead of using the "Active resource" to get the workspace folder.

The following code in activationManager.ts provides that.

    private getActiveResource(): Resource {
        if (this.documentManager.activeTextEditor && !this.documentManager.activeTextEditor.document.isUntitled) {
            return this.documentManager.activeTextEditor.document.uri;
        }
        return Array.isArray(this.workspaceService.workspaceFolders) && workspace.workspaceFolders!.length > 0
            ? workspace.workspaceFolders![0].uri
            : undefined;
    }

@kimadeline
Copy link

✅ Works now:

first venv (opened by default) second venv third venv
image image image

@ghost ghost removed the needs PR label Sep 28, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug
Projects
None yet
Development

No branches or pull requests

5 participants