Skip to content

Commit

Permalink
Merge pull request #854 from schungx/master
Browse files Browse the repository at this point in the history
Fix empty lines bug
  • Loading branch information
schungx authored Mar 25, 2024
2 parents 7de8507 + 08ff3c0 commit 7c76621
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
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

0 comments on commit 7c76621

Please sign in to comment.