diff --git a/src/parser/data.rs b/src/parser/data.rs index 5ab9b62..5925742 100644 --- a/src/parser/data.rs +++ b/src/parser/data.rs @@ -66,11 +66,17 @@ impl Diagnostics { let info: DebugInfo = source.clone().into(); + let context = self.source.get(&info.origin).unwrap() + .lines() + .nth(info.line) + .unwrap() + .trim(); + self.err = Some(DebugNotice { info, msg: message, ext: ext.into(), - source: self.source.get(&info.origin).unwrap().clone(), + source: context.to_string(), }); } diff --git a/src/token/mod.rs b/src/token/mod.rs index 301a97b..5535b95 100644 --- a/src/token/mod.rs +++ b/src/token/mod.rs @@ -446,10 +446,6 @@ impl std::fmt::Display for DebugNotice { f.write_fmt(format_args!( " somewhere in here:\n --> `{}`\n", self.source - .lines() - .nth(self.info.line) - .unwrap() - .trim() .bold() .bright_white() ))