Skip to content

Commit 163cd19

Browse files
authored
Merge pull request RustPython#2519 from TheOnlyError/2406-parse-multiple-lines-REPL
2406 parse multiple lines REPL
2 parents d6c8247 + 3809e49 commit 163cd19

File tree

5 files changed

+72
-28
lines changed

5 files changed

+72
-28
lines changed

Cargo.lock

Lines changed: 64 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ flame = { version = "0.2", optional = true }
4141
flamescope = { version = "0.1", optional = true }
4242

4343
[target.'cfg(not(target_os = "wasi"))'.dependencies]
44-
rustyline = "6.0"
44+
rustyline = "8.0"
4545

4646
[dev-dependencies]
4747
cpython = "0.5.0"

src/shell/helper.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,9 @@ cfg_if::cfg_if! {
163163
.unwrap_or_else(|| (line.len(), vec!["\t".to_owned()])))
164164
}
165165
}
166-
167-
impl Hinter for ShellHelper<'_> {}
166+
impl Hinter for ShellHelper<'_> {
167+
type Hint = String;
168+
}
168169
impl Highlighter for ShellHelper<'_> {}
169170
impl Validator for ShellHelper<'_> {}
170171
impl Helper for ShellHelper<'_> {}

vm/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ uname = "0.1.1"
122122
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
123123
gethostname = "0.2.0"
124124
socket2 = "0.3.19"
125-
rustyline = "6.0"
125+
rustyline = "8.0"
126126
openssl = { version = "0.10.32", features = ["vendored"], optional = true }
127127
openssl-sys = { version = "0.9", optional = true }
128128
openssl-probe = { version = "0.1", optional = true }

vm/src/readline.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,27 +68,21 @@ mod rustyline_readline {
6868
pub trait Helper: rustyline::Helper {}
6969
impl<T: rustyline::Helper> Helper for T {}
7070

71+
/// Readline: the REPL
7172
pub struct Readline<H: Helper> {
7273
repl: rustyline::Editor<H>,
7374
}
7475

7576
impl<H: Helper> Readline<H> {
7677
pub fn new(helper: H) -> Self {
77-
use rustyline::{At, Cmd, CompletionType, Config, Editor, KeyPress, Movement, Word};
78+
use rustyline::*;
7879
let mut repl = Editor::with_config(
7980
Config::builder()
8081
.completion_type(CompletionType::List)
8182
.tab_stop(8)
83+
.bracketed_paste(false) // multi-line paste
8284
.build(),
8385
);
84-
repl.bind_sequence(
85-
KeyPress::ControlLeft,
86-
Cmd::Move(Movement::BackwardWord(1, Word::Vi)),
87-
);
88-
repl.bind_sequence(
89-
KeyPress::ControlRight,
90-
Cmd::Move(Movement::ForwardWord(1, At::AfterEnd, Word::Vi)),
91-
);
9286
repl.set_helper(Some(helper));
9387
Readline { repl }
9488
}

0 commit comments

Comments
 (0)