question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Go to definition in the Editor stopped working after the introspection services migration to use the LSP

See original GitHub issue

Problem Description

Go to definition (Ctrl-G) in the Editor stopped working after PR #4751 was merged.

A minor comment first: the lsp_client_python.log file is taking forever to build and if something introspection related is done while the file is being built, everything seems to break (help, go to definition and code style warnings).

I think the reason that go to definition has stopped working is that there is an error in the path of the file that the language server is returning to Spyder in handle_go_to_definition. An extra / is added at the beginning and the disk name is not capitalized.

For example, let’s say that I Ctrl-G GoToLineDialog on line 1682 of the file codeeditor.py. This file is located on my computer at C:\Users\User\spyder\spyder\widgets\sourcecode\codeeditor.py.

The position['params'] that is returned to handle_go_to_definition is:

{'uri': 'file:///c:/Users/User/spyder/spyder/widgets/sourcecode/codeeditor.py', 
 'range': {'start': {'line': 102, 'character': 6}, 'end': {'line': 102, 'character': 20}},
 'file': '/c:/Users/User/spyder/spyder/widgets/sourcecode/codeeditor.py'
}

So as you can see, the value stored for the file is '/c:/Users/User/spyder/spyder/widgets/sourcecode/codeeditor.py' instead of C:\Users\User\spyder\spyder\widgets\sourcecode\codeeditor.py, the value that is stored in CodeEditor.filename.

If I replace handle_go_to_definition by:

    @handles(LSPRequestTypes.DOCUMENT_DEFINITION)
    def handle_go_to_definition(self, position):
        position = position['params']
        if position is not None:
            def_range = position['range']
            start = def_range['start']
            position_file = osp.normpath(position['file'][1:])
            if osp.normpath(self.filename) == position_file:
                self.go_to_line(start['line'] + 1, start['character'],
                                None, word=None)
            else:
                self.go_to_definition.emit(position_file, start['line'] + 1,
                                           start['character'])

to remove the extra \ and normalize the paths before comparing them, then the go to definition feature is working again as expected.

Versions

  • Spyder version: Spyder 4.0.0.dev0
  • Python version: Python 3.6.5 64bits
  • Qt version: Qt 5.9.3
  • PyQt version: PyQt5 5.9.2
  • Operating System name/version: Windows

Dependencies

pyflakes >=0.6.0  :  1.6.0 (OK)
pycodestyle >=2.3 :  2.3.1 (OK)
pygments >=2.0    :  2.2.0 (OK)
sphinx >=0.6.6    :  1.7.1 (OK)
rope >=0.9.4      :  0.10.7 (OK)
jedi >=0.11.0     :  0.12.1 (OK)
nbconvert >=4.0   :  5.3.1 (OK)
pandas >=0.13.1   :  0.22.0 (OK)
numpy >=1.7       :  1.13.0 (OK)
sympy >=0.7.3     :  1.1.1 (OK)
cython >=0.21     :  0.27.3 (OK)
qtconsole >=4.2.0 :  4.4.0.dev (OK)
IPython >=4.0     :  6.2.1 (OK)
matplotlib >=2.0.0:  2.2.0 (OK)
pylint >=0.25     :  1.8.3 (OK)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:15 (15 by maintainers)

github_iconTop GitHub Comments

1reaction
andfoycommented, Aug 20, 2018

@jnsebgosselin I think this is a Windows-only issue, thanks for pointing out!

0reactions
jnsebgosselincommented, Oct 1, 2018

Ok good. In that case, this is a deal.

Read more comments on GitHub >

github_iconTop Results From Across the Web

LSP go to definition does not work with OmniSharp : r/neovim
I installed OmniSharp like here. The server works and it's attached. The only problem is that when I try to go to definition...
Read more >
RHSA-2022:0056 - Security Advisory - Red Hat 客户门户网站
cloud deployments. This advisory contains the container images for Red Hat OpenShift Container Platform 4.10.3. See the following advisory for ...
Read more >
Jupyter integration with the Language Server Protocol
Summary¶. jupyter(lab)-lsp is a project bringing integration of language-specific IDE features (such as diagnostics, linting, autocompletion, ...
Read more >
IntelliJ IDEA 2019.2.1 (192.6262.58 build) Release Notes
Feature IDEA‑210961 Implement action for Slow Startup Profiling Feature IDEA‑210929 Provide ability to copy a TBX link to a settings Bug IDEA‑207782 Memory leak in...
Read more >
NSX Administration Guide - VMware NSX 4.0
Uninstall an East-West Traffic Introspection Service 444 ... When to Use Policy Mode or Manager Mode (continued). Policy Mode. Manager Mode.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found