Panics when saving a new file without specifying a filename
In prompt, if you try to save without passing a file name and there is not yet a file associated to the buffer's content, it panics.
Steps:
- with 88f55176 and
rustc 1.32.0-nightly (9fefb6766 2018-11-13)
cargo run --features orbital
- enter
insert
mode and write some text - enter
prompt
and executew
Starting Sodium
First redraw of the screen
thread 'main' panicked at 'index out of bounds: the len is 0 but the index is 0', /rustc/9fefb67669f00c25b476e7a80c9c9300a987d517/src/libcore/slice/mod.rs:2447:10
stack backtrace:
0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
1: std::sys_common::backtrace::_print
at libstd/sys_common/backtrace.rs:71
2: std::panicking::default_hook::{{closure}}
at libstd/sys_common/backtrace.rs:59
at libstd/panicking.rs:211
3: std::panicking::default_hook
at libstd/panicking.rs:227
4: std::panicking::rust_panic_with_hook
at libstd/panicking.rs:476
5: std::panicking::continue_panic_fmt
at libstd/panicking.rs:390
6: rust_begin_unwind
at libstd/panicking.rs:325
7: core::panicking::panic_fmt
at libcore/panicking.rs:77
8: core::panicking::panic_bounds_check
at libcore/panicking.rs:59
9: <usize as core::slice::SliceIndex<[T]>>::index
at /rustc/9fefb67669f00c25b476e7a80c9c9300a987d517/src/libcore/slice/mod.rs:2447
10: core::slice::<impl core::ops::index::Index<I> for [T]>::index
at /rustc/9fefb67669f00c25b476e7a80c9c9300a987d517/src/libcore/slice/mod.rs:2315
11: <alloc::vec::Vec<T> as core::ops::index::Index<I>>::index
at /rustc/9fefb67669f00c25b476e7a80c9c9300a987d517/src/liballoc/vec.rs:1653
12: sodium::io::file::<impl sodium::state::editor::Editor>::write
at src/io/file.rs:43
13: sodium::core::prompt::<impl sodium::state::editor::Editor>::invoke
at src/core/prompt.rs:144
14: sodium::core::exec::<impl sodium::state::editor::Editor>::exec
at src/core/exec.rs:279
15: sodium::state::editor::Editor::init
at src/state/editor.rs:321
16: sodium::main
at src/main.rs:24
17: std::rt::lang_start::{{closure}}
at /rustc/9fefb67669f00c25b476e7a80c9c9300a987d517/src/libstd/rt.rs:74
18: std::panicking::try::do_call
at libstd/rt.rs:59
at libstd/panicking.rs:310
19: __rust_maybe_catch_panic
at libpanic_unwind/lib.rs:102
20: std::rt::lang_start_internal
at libstd/panicking.rs:289
at libstd/panic.rs:398
at libstd/rt.rs:58
21: std::rt::lang_start
at /rustc/9fefb67669f00c25b476e7a80c9c9300a987d517/src/libstd/rt.rs:74
22: main
23: __libc_start_main
24: _start