Skip to content

"Fix all" code action on notebook causes panic with multi-byte character #12880

@sato1214syun

Description

@sato1214syun
  • List of keywords you searched for before creating this issue. Write them down here so that others can find this issue more easily and help provide feedback.
    keywords: panic, Q000

  • A minimal code snippet that reproduces the bug.
    test.zip

  • The command you invoked (e.g., ruff /path/to/file.py --fix), ideally including the --isolated flag.
    Implemented formatOnSave of VSCode for notebook

  • The current Ruff settings (any relevant sections from your pyproject.toml).
    ruff.toml.zip

  • The current Ruff version (ruff --version).
    ruff 0.5.7
    ruff vscode extension v2024.40.0

Eror message

2024-08-14 15:23:07.676 [info] panicked at crates/ruff_server/src/edit/range.rs:196:39:
byte index 161 is not a char boundary; it is inside 'あ' (bytes 159..162) of `"""aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa."""
'あaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa`[...]

2024-08-14 15:23:07.678 [info]    0: std::backtrace::Backtrace::force_capture
   1: ruff_server::server::Server::
2024-08-14 15:23:07.678 [info] 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::str::slice_error_fail_rt
   8: core::str::slice_error_fail
   9: <ruff_server::server::api::Error as core::fmt::Display>::fmt
  10: 
2024-08-14 15:23:07.678 [info] <ruff_text_size::range::TextRange as ruff_server::edit::range::ToRangeExt>::to_range
  11: ruff_server::edit::text_document::TextDocument::apply_changes
  12: <ruff_server::server::api::requests::code_action_resolve::CodeActionResolve as ruff_server::server::api::traits::BackgroundDocumentRequestHandler>::run_with_snapshot
  13: <ruff_server::server::api::requests::code_action_resolve::CodeActionResolve as ruff_server
2024-08-14 15:23:07.678 [info] ::server::api::traits::BackgroundDocumentRequestHandler>::run_with_snapshot
  14: <ruff_server::session::capabilities::ResolvedClientCapabilities as core::fmt::Display>::fmt
  15: <ruff_server::server::api::requests::diagnostic::DocumentDiagnostic as ruff_server::server::api::traits::BackgroundDocumentRequestHandler>::run_with_snapshot
  16: <ruff_server::server::api::requests::diagnostic::DocumentDiagnostic as ruff_server::server::api::traits::BackgroundDocumentRequestHandler>::run_with_snapshot
  17: <ruff_server::server::api
2024-08-14 15:23:07.679 [info] ::requests::diagnostic::DocumentDiagnostic as ruff_server::server::api::traits::BackgroundDocumentRequestHandler>::run_with_snapshot
  18: std::sys::pal::unix::thread::Thread::new
  19: __pthread_joiner_wake

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingserverRelated to the LSP server

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions