pylance-release icon indicating copy to clipboard operation
pylance-release copied to clipboard

Popup from documentation does not respect indentation in code blocks

Open jaraqueffdc opened this issue 4 years ago • 3 comments

Environment data

  • VS Code version: 1.61.2
  • Extension version (available under the Extensions sidebar): v2021.10.1365161279
  • OS and version: MacOS 11.5
  • Value of the python.languageServer setting: Pylance

Expected behaviour

When defining a docstring in a method with a markdown code block inside the code block not only does syntax highlighting, which is working perfectly, but also respect the indentation.

Actual behaviour

Indentation in the code block is not respected and all lines of the code are left aligned.

Steps to reproduce:

  1. Create a method with a docstring that includes a markdown code block
  2. Use the method and check the popup that appears where the docstring is rendered

Example

This is a docstring with a code block that won't respect indentation

def function():
    """This is the summary of the method

    ```python
    class A:
        def __init__(self, val):
            self.val = val

        def method(self):
        pass
    ```
    """

And this is what the pop up shows.

Screenshot 2021-10-26 at 11 31 19

Notes

I see that this issue was raised in the past in microsoft/vscode-python#787 but was closed because it was supposed to be fixed but I have never seen it working properly.

jaraqueffdc avatar Oct 26 '21 09:10 jaraqueffdc

What version of pylance r you using?

I'm on the latest. v2021.10.2

hmm. maybe its related to the red squiggles.

you should see "function" in the hover.

image

can you provide the logs from "Python Language Server" output window?

bschnurr avatar Oct 26 '21 17:10 bschnurr

The tooltip from the issue is a signature help (where we omit "(function)" since it's a signature, so must be a function). Maybe we have some lingering docstring inconsistency?

jakebailey avatar Oct 26 '21 18:10 jakebailey

Ah you're right, it is the signature help displaying things differently.

bschnurr avatar Oct 26 '21 18:10 bschnurr

Closing as this appears to be fixed in our latest builds.

Signature help: image

Hover: image

debonte avatar Sep 01 '23 17:09 debonte