Skip to content
This repository has been archived by the owner on Apr 14, 2022. It is now read-only.

use ctrl + click jump to definition as deep as pycharm can do #2052

Closed
fitzlm opened this issue May 26, 2020 · 6 comments
Closed

use ctrl + click jump to definition as deep as pycharm can do #2052

fitzlm opened this issue May 26, 2020 · 6 comments

Comments

@fitzlm
Copy link

fitzlm commented May 26, 2020

Vscode can't jump to definition as deep as pycharm can do.

For example:

from django.shortcuts import render

when i use 'ctrl + click' on "render", it can jump to the render function, but when
i click the method "render_to_string()" inside render function, it can not jump to definition any more, the following is the code snippet:

def render(request, template_name, context=None, content_type=None, status=None, using=None):
    content = loader.render_to_string(template_name, context, request, using=using)
    return HttpResponse(content, content_type, status)

Second example:

import requests
res = requests.get('https://www.google.com')

when i use 'ctrl + click' on "get()", it can jump to the get() function, but when
i click the method "setdefault()" or "request()" inside get() function, it can not jump to definition any more, the following is the code snippet:

def get(url, params=None, **kwargs):
    kwargs.setdefault('allow_redirects', True)
    return request('get', url, params=params, **kwargs)

But when i use pycharm, it can jump to the definition of "render_to_string()" function. So everytime i want to dive into code definition, I must toggle between vscode and pycharm, I feel shame vscode does not have this function. If this extension can add this feature, it would be great!

@karthiknadig karthiknadig transferred this issue from microsoft/vscode-python May 26, 2020
@jakebailey
Copy link
Member

This is expected behavior for performance reasons. Try setting the setting in this comment and see if it works.

#840 (comment)

@fitzlm
Copy link
Author

fitzlm commented May 27, 2020

@jakebailey
Thanks for your help, its useful!

@fitzlm
Copy link
Author

fitzlm commented Jun 16, 2020

@jakebailey I have enabled jedi, but its hard to use, because sometimes it need much time to load the other module when i click 'go to definition'.

@MikhailArkhipov
Copy link

Did you try setting

"python.analysis.memory.keepLibraryAst": true

@fitzlm
Copy link
Author

fitzlm commented Jun 16, 2020

Yes, i have enabled the following:

{"python.analysis.memory.keepLibraryAst": true,
"python.analysis.memory.keepLibraryLocalVariables": true,}

@fitzlm
Copy link
Author

fitzlm commented Jun 16, 2020

@MikhailArkhipov Even though I have jumped into the code definition, when I try to enter again, it is still very slow, as shown in the following:

vscode-debug4

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants