microsoft / vscode-python

Python extension for Visual Studio Code
https://aka.ms/pvsc-marketplace
MIT License
4.25k stars 1.15k forks source link

Go To Definition does not work inside python REPL #23509

Open bhavyaus opened 1 month ago

bhavyaus commented 1 month ago

Testing #23484

Steps:

  1. Create a python file and include the below sample code:
def is_prime(n):
    """Check if a number is prime."""
    if n <= 1:
        return False
    if n <= 3:
        return True
    if n % 2 == 0 or n % 3 == 0:
        return False
    i = 5
    while i * i <= n:
        if n % i == 0 or n % (i + 2) == 0:
            return False
        i += 6
    return True

def generate_primes(limit):
    """Generate a list of prime numbers up to a given limit."""
    primes = []
    for num in range(limit):
        if is_prime(num):
            primes.append(num)
    return primes

limit = 100
primes = generate_primes(limit)
print(f"Prime numbers up to {limit}: {primes}")
print('Hellp World!')
  1. Select the entire contents of the file and run in Python REPL
  2. In the Python REPL cell, right click on generate_primes(limit) and use Go To Definition command.
  3. Expected cursor to jump to the generate_primes definition but the operation results in a no-op
anthonykim1 commented 1 week ago

Just gave this a try with both Python REPL and Interactive Window but I dont think Go To Definition works on either. /cc @amunger Should I transfer this to Pylance or Jupyter?

amunger commented 1 week ago

This might be fixed once we switch to a notebook model with https://github.com/microsoft/vscode/issues/154983. Either way, probably not worth actually fixing until that is done since it would probably change what is needed.