Skip to content

Conversation

WillLillis
Copy link
Contributor

@WillLillis WillLillis commented Mar 18, 2025

Description

Detailed description and repro in #3432. When telescope.builtin.lsp.definitions() is invoked and the target is an empty file, invalid (negative) position values are supplied to nvim's vim.lsp.util.show_document() function resulting in an error. This change clamps the line and character values to a minimum of 0.

Fixes #3432

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list relevant details about your configuration

Configuration:

  • Neovim version (nvim --version):
    NVIM v0.11.0-dev-2016+gf5714994bc
    Build type: RelWithDebInfo
    LuaJIT 2.1.1741730670
  • Operating system and version:
    Ubuntu 22.04

Checklist:

  • My code follows the style guidelines of this project (stylua)
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
    • I don't think a comment is needed with these changes, but I'm happy to add one if it's desired.
  • I have made corresponding changes to the documentation (lua annotations)

Problem: If `telescope.builtin.__lsp.definition` is invoked on an
empty file, `item_to_location` returns a location with `-1` as a
its column value.

Solution: Respectively return 0 if the line or column number is <= 0
Copy link
Contributor

@jamestrew jamestrew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@jamestrew jamestrew merged commit a4ed825 into nvim-telescope:master Mar 19, 2025
12 checks passed
@WillLillis WillLillis deleted the column_range branch March 19, 2025 01:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error encountered when telescope.builtin.lsp.definitions() is invoked and the empty target is an empty file.

2 participants