Skip to content

Definition jump moves to line number in current file if buffer isn't saved #1232

Open
@OJFord

Description

@OJFord

Describe the bug

If the current buffer isn't saved, and not open in another split, LanguageClient#textDocument_definition() is unable to load the file with the definition - which I suppose is desirable - but still then jumps to the definition line number, in the current buffer.

(This also affects LanguageClient#textDocument_references().)

Environment

  • neovim/vim version (nvim --version or vim --version):
    VIM - Vi IMproved 8.2 (2019 Dec 12, compiled May 28 2021 06:58:52)
    Included patches: 1-2891

  • This plugin version (git rev-parse --short HEAD):
    a42594c

  • This plugin's binary version (bin/languageclient --version):

  • Minimal vimrc content (A minimal vimrc is the smallest vimrc that could
    reproduce the issue. Refer to an example [here][min-vimrc.vim]):
    N/A

  • Language server link and version:

  • Pretty sure N/A, but pylsp v1.2.0
    https://github.com/python-lsp/python-lsp-server

To Reproduce

  1. Open a file that calls a function defined in another on a different line number (examples below)
  2. Make some (any) edit, without saving (e.g. add whitespace to end of line in example)
  3. Place cursor on function (L3 in example)
  4. :call LanguageClient#textDocument_definition()
# caller.py L1
if True:
    fn()
# callee.py L1
def fn():
    pass

Current behavior

Cursor jumps to line number of function definition (L2 in example), in current unsaved buffer (caller.py in example, not containing defn).

Expected behavior

Cursor doesn't move, (L3 in example) some error message.

Screenshots

N/A

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions