From 06608affc5b772f670f07e3f03f32ce2fcd609ce Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Mon, 11 Apr 2022 16:32:23 +0800 Subject: [PATCH] Fix rustyline patch. --- CHANGELOG.md | 5 +++-- Cargo.toml | 2 +- src/bin/rhai-repl.rs | 23 +++++++++-------------- 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6fa3f6f9..f00032aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,13 +1,14 @@ Rhai Release Notes ================== -Version 1.7.0 +Version 1.6.1 ============= Bug fixes --------- * Functions with `Dynamic` parameters now work in qualified calls from `import`ed modules. +* `rhai-repl` now compiles with the new patch version of `rustyline`. Script-breaking changes ----------------------- @@ -18,7 +19,7 @@ Script-breaking changes Enhancements ------------ -* Strings are not directly iterable (via `for .. in`) yielding individual characters. +* Strings are now directly iterable (via `for .. in`) yielding individual characters. Version 1.6.0 diff --git a/Cargo.toml b/Cargo.toml index c103eabf..47de2213 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ members = [".", "codegen"] [package] name = "rhai" -version = "1.7.0" +version = "1.6.1" rust-version = "1.57" edition = "2018" authors = ["Jonathan Turner", "Lukáš Hozda", "Stephen Chung", "jhwgh1968"] diff --git a/src/bin/rhai-repl.rs b/src/bin/rhai-repl.rs index 87494edf..c0dfa093 100644 --- a/src/bin/rhai-repl.rs +++ b/src/bin/rhai-repl.rs @@ -3,7 +3,6 @@ use rhai::{Dynamic, Engine, EvalAltResult, Module, Scope, AST, INT}; use rustyline::config::Builder; use rustyline::error::ReadlineError; use rustyline::{Cmd, Editor, Event, EventHandler, KeyCode, KeyEvent, Modifiers, Movement}; -use smallvec::smallvec; use std::{env, fs::File, io::Read, path::Path, process::exit}; @@ -223,40 +222,40 @@ fn setup_editor() -> Editor<()> { // On Windows, Esc clears the input buffer #[cfg(target_family = "windows")] rl.bind_sequence( - Event::KeySeq(smallvec![KeyEvent(KeyCode::Esc, Modifiers::empty())]), + Event::KeySeq(vec![KeyEvent(KeyCode::Esc, Modifiers::empty())]), EventHandler::Simple(Cmd::Kill(Movement::WholeBuffer)), ); // On Windows, Ctrl-Z is undo #[cfg(target_family = "windows")] rl.bind_sequence( - Event::KeySeq(smallvec![KeyEvent::ctrl('z')]), + Event::KeySeq(vec![KeyEvent::ctrl('z')]), EventHandler::Simple(Cmd::Undo(1)), ); // Map Ctrl-Enter to insert a new line - bypass need for `\` continuation rl.bind_sequence( - Event::KeySeq(smallvec![KeyEvent(KeyCode::Char('J'), Modifiers::CTRL)]), + Event::KeySeq(vec![KeyEvent(KeyCode::Char('J'), Modifiers::CTRL)]), EventHandler::Simple(Cmd::Newline), ); rl.bind_sequence( - Event::KeySeq(smallvec![KeyEvent(KeyCode::Enter, Modifiers::CTRL)]), + Event::KeySeq(vec![KeyEvent(KeyCode::Enter, Modifiers::CTRL)]), EventHandler::Simple(Cmd::Newline), ); // Map Ctrl-Home and Ctrl-End for beginning/end of input rl.bind_sequence( - Event::KeySeq(smallvec![KeyEvent(KeyCode::Home, Modifiers::CTRL)]), + Event::KeySeq(vec![KeyEvent(KeyCode::Home, Modifiers::CTRL)]), EventHandler::Simple(Cmd::Move(Movement::BeginningOfBuffer)), ); rl.bind_sequence( - Event::KeySeq(smallvec![KeyEvent(KeyCode::End, Modifiers::CTRL)]), + Event::KeySeq(vec![KeyEvent(KeyCode::End, Modifiers::CTRL)]), EventHandler::Simple(Cmd::Move(Movement::EndOfBuffer)), ); // Map Ctrl-Up and Ctrl-Down to skip up/down the history, even through multi-line histories rl.bind_sequence( - Event::KeySeq(smallvec![KeyEvent(KeyCode::Down, Modifiers::CTRL)]), + Event::KeySeq(vec![KeyEvent(KeyCode::Down, Modifiers::CTRL)]), EventHandler::Simple(Cmd::NextHistory), ); rl.bind_sequence( - Event::KeySeq(smallvec![KeyEvent(KeyCode::Up, Modifiers::CTRL)]), + Event::KeySeq(vec![KeyEvent(KeyCode::Up, Modifiers::CTRL)]), EventHandler::Simple(Cmd::PreviousHistory), ); @@ -371,11 +370,7 @@ fn main() { input.clear(); loop { - let prompt = if input.is_empty() { - "rhai-repl> " - } else { - " > " - }; + let prompt = if input.is_empty() { "repl> " } else { " > " }; match rl.readline(prompt) { // Line continuation