-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Panic Error in Python with Pyright/Pylsp & Ruff #10689
Comments
Looking at the backtrace I believe one of the language servers is sending us a range for the completion item that is beyond the end of the document and we need to handle that case when turning completion items into transactions. |
Yes. |
For some reason, it is fixed and working as-expected if instead of doing : fn find_completion_range(text: RopeSlice, replace_mode: bool, cursor: usize) -> (usize, usize) {
let start = cursor
- text
.chars_at(cursor)
.reversed()
.take_while(|ch| chars::char_is_word(*ch))
.count();
let mut end = cursor;
if replace_mode {
end += text
.chars_at(cursor)
.skip(1)
.take_while(|ch| chars::char_is_word(*ch))
.count()
+ 1;
}
(start, end)
} as was changed in #10279 fn find_completion_range(text: RopeSlice, replace_mode: bool, cursor: usize) -> (usize, usize) {
let start = cursor
- text
.chars_at(cursor)
.reversed()
.take_while(|ch| chars::char_is_word(*ch))
.count();
let mut end = cursor;
if replace_mode {
end += text
.chars_at(cursor)
.skip(1)
.take_while(|ch| chars::char_is_word(*ch))
.count();
}
(start, end)
} I have tested extensively using JS/TS, Rust & Python. This fixes the main issue that was happening before. There still is an ongoing issue where in Python the next-line gets concatenated to the current line and the next-line's first element (-1) gets replaced if doing an autocomplete, only when using Python. See video: Screen.Recording.2024-05-15.at.2.32.32.PM.mov
Might be worth investigating. I'm playing around with the codebase but I have just now started to get a little bit more familiar with it. @the-mikedavis |
Was this when you ran master? |
Yes, on master. |
Summary
Had the same error happen using Pylsp.
Here is my
languages.toml
for python:MOV.to.MP4.conversion.mp4
Reproduction Steps
I tried this:
hx main.py
<space>-K
), coming back & forth ~3 timesI expected this to happen:
Instead, this happened:
Helix log
RUST_BACKTRACE=1
``` hx . thread 'main' panicked at 'Attempt to slice past end of RopeSlice: slice end 202, RopeSlice length 201', /Users/brain/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ropey-1.6.1/src/slice.rs:656:9 stack backtrace: 0: _rust_begin_unwind 1: core::panicking::panic_fmt 2: ropey::slice::RopeSlice::slice 3: helix_lsp::util::generate_transaction_from_completion_edit 4: helix_term::ui::completion::Completion::new::{{closure}}::item_to_transaction 5: helix_term::ui::completion::Completion::new::{{closure}} 6: as helix_term::compositor::Component>::handle_event 7: as helix_term::compositor::Component>::handle_event 8: ::handle_event 9: helix_term::compositor::Compositor::handle_event 10: helix_term::application::Application::run::{{closure}} 11: tokio::runtime::park::CachedParkThread::block_on 12: tokio::runtime::context::runtime::enter_runtime 13: tokio::runtime::runtime::Runtime::block_on 14: hx::main note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.```~/.cache/helix/helix.log
``` 2024-05-05T15:12:06.671 helix_lsp::transport [ERROR] ruff-lsp err <- "Ignoring notification for unknown method \"workspace/didChangeConfiguration\"\n" 2024-05-05T15:12:12.560 helix_lsp::transport [ERROR] ruff-lsp err <- "Ignoring notification for unknown method \"workspace/didChangeConfiguration\"\n" 2024-05-05T15:12:47.351 helix_lsp::transport [ERROR] ruff-lsp err <- "Ignoring notification for unknown method \"workspace/didChangeConfiguration\"\n" 2024-05-05T15:13:17.618 helix_lsp::transport [ERROR] Tried sending response into a closed channel (id=Num(14)), original request likely timed out 2024-05-05T15:13:46.147 helix_lsp::transport [ERROR] ruff-lsp err: <- StreamClosed 2024-05-05T15:13:46.147 helix_lsp [ERROR] client was already removed 2024-05-05T15:13:46.149 helix_lsp::transport [ERROR] pyright err: <- StreamClosed 2024-05-05T15:13:46.149 helix_lsp [ERROR] client was already removed 2024-05-05T15:13:46.364 helix_lsp::transport [ERROR] ruff-lsp err <- "Ignoring notification for unknown method \"workspace/didChangeConfiguration\"\n" 2024-05-05T15:14:59.807 helix_lsp::transport [ERROR] ruff-lsp err <- "Ignoring notification for unknown method \"workspace/didChangeConfiguration\"\n" 2024-05-05T15:15:08.013 helix_lsp::util [WARN] LSP position Position { line: 13, character: 0 } out of range assuming EOF ```Platform
macOS
Terminal Emulator
Warp
Installation Method
source
Helix Version
helix 24.3 (cfca308)
The text was updated successfully, but these errors were encountered: