Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

:goto should not crash if it doesn't input the line number? #1159

Closed
wingyplus opened this issue Nov 24, 2021 · 4 comments · Fixed by #1160
Closed

:goto should not crash if it doesn't input the line number? #1159

wingyplus opened this issue Nov 24, 2021 · 4 comments · Fixed by #1160
Labels
A-helix-term Area: Helix term improvements C-bug Category: This is a bug

Comments

@wingyplus
Copy link
Contributor

I'm not sure is it a bug. The :goto command will be panic if I just typing :goto and enter. The stacktrace is:

thread 'main' panicked at 'index out of bounds: the len is 0 but the index is 0', helix-term/src/commands.rs:2489:20
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
@wingyplus
Copy link
Contributor Author

More info with RUST_BACKTRACE:

thread 'main' panicked at 'index out of bounds: the len is 0 but the index is 0', helix-term/src/commands.rs:2489:20
stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic_bounds_check
   3: helix_term::commands::cmd::goto_line_number
   4: helix_term::commands::command_mode::{{closure}}
   5: <helix_term::ui::prompt::Prompt as helix_term::compositor::Component>::handle_event
   6: helix_term::application::Application::handle_terminal_events
   7: helix_term::application::Application::run::{{closure}}
   8: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
   9: tokio::park::thread::CachedParkThread::block_on
  10: tokio::runtime::thread_pool::ThreadPool::block_on
  11: tokio::runtime::Runtime::block_on
  12: hx::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

@archseer
Copy link
Member

\cc @s1ck

wingyplus added a commit to wingyplus/helix that referenced this issue Nov 24, 2021
If the user enter `:goto` command without entering a line number, the editor
will stay on the current line.

Fixes helix-editor#1159
wingyplus added a commit to wingyplus/helix that referenced this issue Nov 24, 2021
If the user enter `:goto` command without entering a line number, the editor
will stay on the current line.

Fixes helix-editor#1159
@wingyplus
Copy link
Contributor Author

I opened a PR to be an opinion. Hope this would help. 🙇

@s1ck
Copy link
Contributor

s1ck commented Nov 24, 2021

Thanks for reporting the issue. I can review it later :)

wingyplus added a commit to wingyplus/helix that referenced this issue Nov 24, 2021
Report an error when running goto command without entering a
line number.

Fixes helix-editor#1159
@kirawi kirawi added A-helix-term Area: Helix term improvements C-bug Category: This is a bug labels Nov 25, 2021
archseer pushed a commit that referenced this issue Nov 25, 2021
* Do not crash when run goto command without line number

Report an error when running goto command without entering a
line number.

Fixes #1159

* Use is_empty() instead check len zero
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-helix-term Area: Helix term improvements C-bug Category: This is a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants