astral-sh / ruff-vscode

A Visual Studio Code extension with support for the Ruff linter.
Other
1.11k stars 53 forks source link

Server panic when shuffling a mixed of code and markdown cells #575

Open dhruvmanila opened 2 months ago

dhruvmanila commented 2 months ago

Huh, this did give me the following (unrelated) panic though:

2024-08-07 15:37:33.967 [info] panicked at crates/ruff_server/src/server/api/requests/format.rs:67:10:
format should only be called on text documents or notebook cells

2024-08-07 15:37:33.975 [info]    0: std::backtrace::Backtrace::force_capture
   1: ruff_server::server::Server::run
   2: std::panicking::rust_panic_with_hook
   3: <std::panicking::begin_panic_handler::StaticStrPayload as core::panic::PanicPayload>::take_box
   4: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
   5: _rust_begin_unwind
   6: core::panicking::panic_fmt
   7: core::option::expect_failed
   8: <ruff_server::server::api::requests::format::Format as ruff_server::server::api::traits::BackgroundDocumentRequestHandler>::run_with_snapshot
   9: ruff_server::session::Session::take_snapshot
  10: ruff_python_trivia::pragmas::is_pragma_comment
  11: <ruff_server::server::api::requests::hover::Hover as ruff_server::server::api::traits::BackgroundDocumentRequestHandler>::run_with_snapshot
  12: <ruff_server::server::api::requests::hover::Hover as ruff_server::server::api::traits::BackgroundDocumentRequestHandler>::run_with_snapshot
  13: std::sys::pal::unix::thread::Thread::new
  14: __pthread_joiner_wake

And, then the editor hangs at "Saving 'issue.ipynb'"

Originally posted by @dhruvmanila in https://github.com/astral-sh/ruff-vscode/issues/573#issuecomment-2273109308

dhruvmanila commented 2 months ago

I'm able to reproduce this every time but it's just reliably know the order in which to move the cells.