https://bugs.kde.org/show_bug.cgi?id=522208

            Bug ID: 522208
           Summary: LSP documentHighlight request sent with invalid cursor
                    position when pressing Enter in the end of Python
                    files
    Classification: Applications
           Product: kate
      Version First 25.04.3
       Reported In:
          Platform: Debian stable
                OS: Linux
            Status: REPORTED
          Severity: minor
          Priority: NOR
         Component: application
          Assignee: [email protected]
          Reporter: [email protected]
  Target Milestone: ---

**Title**

LSP documentHighlight request sent with invalid cursor position when pressing
Enter in Python files

**Environment**

* Kate 25.04.3
* Debian (testing/unstable)
* Python 3.13.5
* python-lsp-server 1.12.0
* Jedi 0.19.1

**Description**

When editing any Python file with the LSP client enabled and "Highlight symbol
under cursor" enabled, pressing Enter at the end of a line causes the Python
LSP server to log the following exception repeatedly:

```
WARNING - pylsp.config.config - Failed to load hook pylsp_document_highlight:
ValueError: `line` parameter is not in a valid range.
```

The traceback originates from:

```
pylsp.plugins.highlight
→ jedi.api.helpers
→ ValueError: `line` parameter is not in a valid range.
```

The warning appears every time Enter is pressed.

Disabling **"Highlight symbol under cursor"** in Kate's LSP Client settings
immediately stops the warnings.

All other LSP functionality (completion, diagnostics, hover, etc.) continues to
work normally.

**Steps to reproduce**

1. Open Kate.
2. Enable the LSP Client.
3. Enable "Highlight symbol under cursor".
4. Open any Python file.
5. Place the cursor at the end of a line.
6. Press Enter.
7. Observe the Python LSP server log.

**Expected behavior**

Kate should not send a `documentHighlight` request with an invalid position. No
exceptions should be generated by the language server.

**Actual behavior**

The language server receives a `documentHighlight` request that ultimately
results in:

```
ValueError: `line` parameter is not in a valid range.
```

Disabling "Highlight symbol under cursor" avoids the issue entirely.

Traceback:
```
2026-06-26 13:40:36,028 +05 - WARNING - pylsp.config.config - Failed to load
hook pylsp_document_highlight: `line` parameter is not in a valid range.
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/pylsp/config/config.py", line 39, in
_hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
           ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/pluggy/_manager.py", line 480, in
traced_hookexec
    return outcome.get_result()
           ~~~~~~~~~~~~~~~~~~^^
  File "/usr/lib/python3/dist-packages/pluggy/_result.py", line 100, in
get_result
    raise exc.with_traceback(exc.__traceback__)
  File "/usr/lib/python3/dist-packages/pluggy/_result.py", line 62, in
from_call
    result = func()
  File "/usr/lib/python3/dist-packages/pluggy/_manager.py", line 477, in
<lambda>
    lambda: oldcall(hook_name, hook_impls, caller_kwargs, firstresult)
            ~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/pluggy/_callers.py", line 139, in
_multicall
    raise exception.with_traceback(exception.__traceback__)
  File "/usr/lib/python3/dist-packages/pluggy/_callers.py", line 103, in
_multicall
    res = hook_impl.function(*args)
  File "/usr/lib/python3/dist-packages/pylsp/plugins/highlight.py", line 14, in
pylsp_document_highlight
    usages = document.jedi_script().get_references(**code_position)
  File "/usr/lib/python3/dist-packages/jedi/api/helpers.py", line 473, in
wrapper
    raise ValueError('`line` parameter is not in a valid range.')
ValueError: `line` parameter is not in a valid range.
```

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to