diff options
author | sigmaSd <bedisnbiba@gmail.com> | 2022-06-15 01:19:06 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-15 02:19:06 +0200 |
commit | 8bfa89a478d6ebef32cf6c93d4cdc45e4a1cc550 (patch) | |
tree | f1ba05985ec1852050e76f556a5ed3fd097859de | |
parent | 4cff05b275726c027ec75d524c1e704d62cc74e3 (diff) |
feat(repl): Add key binding to force a new line (#14536)
This commit adds key binding for "ctrl+s"
combination that will force a new line in REPL.
-rw-r--r-- | cli/tools/repl/editor.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/cli/tools/repl/editor.rs b/cli/tools/repl/editor.rs index 82719f27a..502134ebc 100644 --- a/cli/tools/repl/editor.rs +++ b/cli/tools/repl/editor.rs @@ -14,10 +14,15 @@ use rustyline::highlight::Highlighter; use rustyline::validate::ValidationContext; use rustyline::validate::ValidationResult; use rustyline::validate::Validator; +use rustyline::Cmd; use rustyline::CompletionType; use rustyline::Config; use rustyline::Context; use rustyline::Editor; +use rustyline::EventHandler; +use rustyline::KeyCode; +use rustyline::KeyEvent; +use rustyline::Modifiers; use rustyline_derive::{Helper, Hinter}; use std::borrow::Cow; use std::path::PathBuf; @@ -360,6 +365,10 @@ impl ReplEditor { let mut editor = Editor::with_config(editor_config); editor.set_helper(Some(helper)); editor.load_history(&history_file_path).unwrap_or(()); + editor.bind_sequence( + KeyEvent(KeyCode::Char('s'), Modifiers::CTRL), + EventHandler::Simple(Cmd::Newline), + ); ReplEditor { inner: Arc::new(Mutex::new(editor)), |