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

Go To Definition using Jedi only moves cursor #7280

Closed
OutOfFocus4 opened this issue Sep 7, 2019 · 3 comments
Closed

Go To Definition using Jedi only moves cursor #7280

OutOfFocus4 opened this issue Sep 7, 2019 · 3 comments
Labels
area-intellisense LSP-related functionality: auto-complete, docstrings, navigation, refactoring, etc. bug Issue identified by VS Code Team member as probable bug regression Bug didn't exist in a previous release verified Verification succeeded

Comments

@OutOfFocus4
Copy link

Issue Type: Bug

Since the latest update, when I try to use "Go To Definition" to open a file in my project's venv, it only moves the cursor.

Everything works if I switch to the language server.

Steps to reproduce:

Create a Python file with the following contents:

from unittest import TestCase


class MyTestCase(TestCase):
	def test_example(self):
		with self.assertRaises(ZeroDivisionError):
			value = 1 / 0
		self.assertNotEqual(value, 1)

CTRL + click on assertRaises or assertNotEqual. The cursor will move to the last line of the file.

The problem isn't in Jedi, since the following script gives the correct output:

import jedi

with open('tests.py') as file:
	source = file.read()

script = jedi.Script(source=source, line=6, column=24)
definition = script.goto_definitions()[0]
print('Definition Module: ', definition.module_name)  # prints "Definition Module:  case"
print('Definition Module Path: ', definition.module_path)  # prints "Definition Module Path:  /usr/lib/python3.6/unittest/case.py"

Extension version: 2019.9.34911
VS Code version: Code 1.38.0 (3db7e09f3b61f915d03bbfa58e258d6eee843f35, 2019-09-03T21:51:09.716Z)
OS version: Linux x64 4.15.0-60-generic snap

System Info
Item Value
CPUs Intel(R) Core(TM) i5-4210U CPU @ 1.70GHz (4 x 2368)
GPU Status 2d_canvas: unavailable_software
flash_3d: disabled_software
flash_stage3d: disabled_software
flash_stage3d_baseline: disabled_software
gpu_compositing: disabled_software
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: disabled_software
oop_rasterization: disabled_off
protected_video_decode: disabled_off
rasterization: disabled_software
skia_deferred_display_list: disabled_off
skia_renderer: disabled_off
surface_synchronization: enabled_on
video_decode: disabled_software
viz_display_compositor: disabled_off
webgl: unavailable_software
webgl2: unavailable_software
Load (avg) 2, 2, 1
Memory (System) 7.68GB (4.51GB free)
Process Argv
Screen Reader no
VM 0%
@ghost ghost added the triage-needed Needs assignment to the proper sub-team label Sep 7, 2019
@OutOfFocus4 OutOfFocus4 changed the title Go To Definition using Jedi won't only moves cursor Go To Definition using Jedi only moves cursor Sep 7, 2019
@kimadeline kimadeline self-assigned this Sep 9, 2019
@ghost ghost removed the triage-needed Needs assignment to the proper sub-team label Sep 9, 2019
@kimadeline kimadeline added the bug Issue identified by VS Code Team member as probable bug label Sep 9, 2019
@kimadeline
Copy link

kimadeline commented Sep 9, 2019

Hi @OutOfFocus4 👋 Thank you for reporting this issue and providing sample code 👍 I could reproduce this issue locally, can confirm that it appeared when we updated the extension to use jedi 0.15.1, so in version 2019.9.34474 and onwards.

Notes

  • Updating L.577 of pythonFiles/completion.py with defs = self._get_definitionsx(script.goto_definitions(), request["id"]) seems to fix the issue, but:
    • I don't know if we need to set the ignoreNoModulePath parameter to True (like on L.583 and L.588)
    • we may want to keep using goto_assignments, which would require further investigation 🔍
    • there may be other side effects
  • No issues with jedi 0.14.0
  • Is this related: goto_assignement goes to the stub and not the actual implementation davidhalter/jedi#1423 ?

if lookup == 'definitions':
defs = self._get_definitionsx(script.goto_assignments(follow_imports=True), request['id'])
return json.dumps({'id': request['id'], 'results': defs})

  • Using the language server sends you to L.1 of path/to/python/libpython3.7/unittest/__init__.py instead of path/to/python/lib/python3.7/unittest/case.py

@kimadeline kimadeline removed their assignment Sep 9, 2019
@kimadeline kimadeline added area-intellisense LSP-related functionality: auto-complete, docstrings, navigation, refactoring, etc. needs PR regression Bug didn't exist in a previous release and removed triage labels Sep 9, 2019
@luabud
Copy link
Member

luabud commented Nov 24, 2020

Once #11995 is addressed we should see if this is fixed by it

@karthiknadig karthiknadig added this to the September 2021 milestone Sep 21, 2021
@karthiknadig
Copy link
Member

This is fixed with Jedi behind LSP.

@karthiknadig karthiknadig added the verified Verification succeeded label Sep 21, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-intellisense LSP-related functionality: auto-complete, docstrings, navigation, refactoring, etc. bug Issue identified by VS Code Team member as probable bug regression Bug didn't exist in a previous release verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

4 participants