gchp / iota

A terminal-based text editor written in Rust
MIT License
1.62k stars 80 forks source link

thread '<main>' panicked at 'index out of bounds: the len is 0 but the index is 0', ../src/libcollections/vec.rs:1134 #111

Closed dpc closed 8 years ago

dpc commented 8 years ago
env RUST_BACKTRACE=1 ./target/release/iota --vi
thread '<main>' panicked at 'index out of bounds: the len is 0 but the index is 0', ../src/libcollections/vec.rs:1134
stack backtrace:
   1:     0x55e8bfa2d130 - sys::backtrace::tracing::imp::write::hf66cd359dc225f8a0nu
   2:     0x55e8bfa2f75b - panicking::default_handler::_<closure>::closure.42795
   3:     0x55e8bfa2f324 - panicking::default_handler::h74bfdb4a758a82e9EFy
   4:     0x55e8bfa215f6 - sys_common::unwind::begin_unwind_inner::h9d3a2e7a2c681f25ygt
   5:     0x55e8bfa21a78 - sys_common::unwind::begin_unwind_fmt::h4fadd261b35ed9d7Eft
   6:     0x55e8bfa2c771 - rust_begin_unwind
   7:     0x55e8bfa5c37f - panicking::panic_fmt::h596d44ac9aaebe47nYL
   8:     0x55e8bfa5c4f2 - panicking::panic_bounds_check::hb399db976cf4f929tXL
   9:     0x55e8bf9acd24 - buffer::Buffer::get_object_index::hee931b9597f98e70Xqa
  10:     0x55e8bf9b0b46 - view::View::move_mark::h50c3269b4d699f3cXIb
  11:     0x55e8bf9a7192 - main::h07af46f8e193902eeda
  12:     0x55e8bfa2efc4 - sys_common::unwind::try::try_fn::h3732045691669936705
  13:     0x55e8bfa2c708 - __rust_try
  14:     0x55e8bfa2ebfd - rt::lang_start::h2071a016df0a133cKxy
  15:     0x7f998bb4357f - __libc_start_main
  16:     0x55e8bf9a4cb8 - _start
  17:                0x0 - <unknown>
gchp commented 8 years ago

Hi @dpc!

Are you running off the latest master? I just re-built my copy and don't see this issue. The latest commit in your tree should be c349d0b4e4021730650ab4c235c4c23c9bc0f8f0?

dpc commented 8 years ago

Yesterdays master branch, yes. In vi mode use j on an empty buffer.

cbresendiz1 commented 8 years ago

I can confirm it. Adding text, returning to normal mode, and using 'j' will produce the same error, too. The latest commit, c349d0b, is in the source directory.

gchp commented 8 years ago

Yep, I see it too. It happens when you try move to the end of any buffer, regardless of content or editor mode. The source of the issue is get_line_index_forward in buffer.rs. Trying to find a nice solution at the moment...

crespyl commented 8 years ago

On line 330, nlines is a list of the buffer indices of all the newlines after the mark. We just need to check to make sure the list isn't empty, and return None if it is.

gchp commented 8 years ago

@crespyl yep, just pushed the fix. Thanks!

Thanks everyone for making me aware of the issue!