Skip to content

'Go to definition' prefers root of repo, even if outside of project folder #2585

@sebastian-b

Description

@sebastian-b

Environment data

  • VS Code version: 1.27.2
  • Extension version (available under the Extensions sidebar): 2018.8.0
  • OS and version: Mac OS 10.13.6
  • Python version (& distribution if applicable, e.g. Anaconda): XXX
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): conda
  • Relevant/affected Python packages and their versions: Python 3.6

Actual behavior

"Go to definition" looks in the wrong path in the root of the repository, when its name matches the file in the currently opened folder.

This only happens, when the project is a subfolder of a repository. If the .git folder is removed, it works as expected.

Maybe this is related to issue 2555? Using the language server with "python.jediEnabled": false also avoids this problem.

Expected behavior

Ignore files in the root of the repository, if outside of project (or reduce priority).

Steps to reproduce:

Given the following folders:

.git
project/
    .vscode/
        settings.json
    main.py
    utils.py
utils.py
  1. Open the folder project/ in vscode
  2. Open the file main.py
  3. Use "Go to definition" on import utils

vscode jumps to /utils.py instead of project/utils.py, even though it is outside the project.

If the /.git folder is removed, it works as expected. Running python main.py works as expected in any case.

Logs

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

##########Linting Output - pylint##########

--------------------------------------------------------------------
Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)

Output from Console under the Developer Tools panel (toggle Developer Tools on under Help)

(no output)

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-editor-*User-facing catch-allarea-intellisenseLSP-related functionality: auto-complete, docstrings, navigation, refactoring, etc.bugIssue identified by VS Code Team member as probable bugverifiedVerification succeeded

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions