mirror of
https://github.com/denoland/deno.git
synced 2025-01-03 04:48:52 -05:00
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.
This commit is contained in:
parent
4cff05b275
commit
8bfa89a478
1 changed files with 9 additions and 0 deletions
|
@ -14,10 +14,15 @@ use rustyline::highlight::Highlighter;
|
||||||
use rustyline::validate::ValidationContext;
|
use rustyline::validate::ValidationContext;
|
||||||
use rustyline::validate::ValidationResult;
|
use rustyline::validate::ValidationResult;
|
||||||
use rustyline::validate::Validator;
|
use rustyline::validate::Validator;
|
||||||
|
use rustyline::Cmd;
|
||||||
use rustyline::CompletionType;
|
use rustyline::CompletionType;
|
||||||
use rustyline::Config;
|
use rustyline::Config;
|
||||||
use rustyline::Context;
|
use rustyline::Context;
|
||||||
use rustyline::Editor;
|
use rustyline::Editor;
|
||||||
|
use rustyline::EventHandler;
|
||||||
|
use rustyline::KeyCode;
|
||||||
|
use rustyline::KeyEvent;
|
||||||
|
use rustyline::Modifiers;
|
||||||
use rustyline_derive::{Helper, Hinter};
|
use rustyline_derive::{Helper, Hinter};
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
@ -360,6 +365,10 @@ impl ReplEditor {
|
||||||
let mut editor = Editor::with_config(editor_config);
|
let mut editor = Editor::with_config(editor_config);
|
||||||
editor.set_helper(Some(helper));
|
editor.set_helper(Some(helper));
|
||||||
editor.load_history(&history_file_path).unwrap_or(());
|
editor.load_history(&history_file_path).unwrap_or(());
|
||||||
|
editor.bind_sequence(
|
||||||
|
KeyEvent(KeyCode::Char('s'), Modifiers::CTRL),
|
||||||
|
EventHandler::Simple(Cmd::Newline),
|
||||||
|
);
|
||||||
|
|
||||||
ReplEditor {
|
ReplEditor {
|
||||||
inner: Arc::new(Mutex::new(editor)),
|
inner: Arc::new(Mutex::new(editor)),
|
||||||
|
|
Loading…
Reference in a new issue