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

Fix empty lines bug #854

Merged
merged 1 commit into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/bin/rhai-dbg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ fn print_current_source(

/// Pretty-print error.
fn print_error(input: &str, mut err: EvalAltResult) {
let lines: Vec<_> = input.trim().lines().collect();
// Do not use `line` because it "eats" the last empty line if the script ends with a newline.
let lines: Vec<_> = input.split('\n').collect();
let pos = err.take_position();

let line_no = if lines.len() > 1 {
Expand Down
3 changes: 2 additions & 1 deletion src/bin/rhai-repl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ const HISTORY_FILE: &str = ".rhai-repl-history";

/// Pretty-print error.
fn print_error(input: &str, mut err: EvalAltResult) {
let lines: Vec<_> = input.lines().collect();
// Do not use `line` because it "eats" the last empty line if the script ends with a newline.
let lines: Vec<_> = input.split('\n').collect();
let pos = err.take_position();

let line_no = if lines.len() > 1 {
Expand Down
3 changes: 2 additions & 1 deletion src/bin/rhai-run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ fn eprint_error(input: &str, mut err: EvalAltResult) {
eprintln!();
}

let lines: Vec<_> = input.lines().collect();
// Do not use `line` because it "eats" the last empty line if the script ends with a newline.
let lines: Vec<_> = input.split('\n').collect();

// Print error
let pos = err.take_position();
Expand Down