Skip to content

Panic when pressing Shift + Tab in an empty line #112

@Fulgen301

Description

@Fulgen301

When Shift+Tab is pressed at the beginning of an empty line, edit crashes with a panic.

edit version: e8d40f6
Built with: rustc 1.89.0-nightly (60dabef95 2025-05-19)

thread 'main' panicked at src\buffer\mod.rs:1995:27:
index out of bounds: the len is 0 but the index is 0
stack backtrace:
   0: std::panicking::begin_panic_handler
             at /rustc/60dabef95a3de3ec974dcb50926e4bfe743f078f/library\std\src\panicking.rs:697
   1: core::panicking::panic_fmt
             at /rustc/60dabef95a3de3ec974dcb50926e4bfe743f078f/library\core\src\panicking.rs:75
   2: core::panicking::panic_bounds_check
             at /rustc/60dabef95a3de3ec974dcb50926e4bfe743f078f/library\core\src\panicking.rs:280
   3: core::slice::index::impl$2::index<u8>
             at C:\Users\<username>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\slice\index.rs:274
   4: alloc::vec::impl$13::index<u8,usize,alloc::alloc::Global>
             at C:\Users\<username>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\alloc\src\vec\mod.rs:3376
   5: edit::buffer::TextBuffer::unindent
             at .\src\buffer\mod.rs:1995
   6: edit::tui::Context::textarea_handle_input
             at .\src\tui.rs:2268
   7: edit::tui::Context::textarea_internal
             at .\src\tui.rs:2068
   8: edit::tui::Context::textarea
             at .\src\tui.rs:1981
   9: edit::draw_editor::draw_editor
             at .\src\bin\edit\draw_editor.rs:27
  10: edit::draw
             at .\src\bin\edit\main.rs:289
  11: edit::run
             at .\src\bin\edit\main.rs:137
  12: edit::main
             at .\src\bin\edit\main.rs:50
  13: core::ops::function::FnOnce::call_once<std::process::ExitCode (*)(),tuple$<> >
             at C:\Users\<username>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\ops\function.rs:250

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions