From 962b258cc6e1d77d68fbf6d9b86356dc1834513b Mon Sep 17 00:00:00 2001 From: Fernando Herrera Date: Wed, 22 Sep 2021 20:48:05 +0100 Subject: [PATCH] merge span (#4031) --- crates/nu-protocol/src/dataframe/compute_between.rs | 2 +- crates/nu-source/src/meta.rs | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/crates/nu-protocol/src/dataframe/compute_between.rs b/crates/nu-protocol/src/dataframe/compute_between.rs index 627b71eaf..fa5e02849 100644 --- a/crates/nu-protocol/src/dataframe/compute_between.rs +++ b/crates/nu-protocol/src/dataframe/compute_between.rs @@ -21,7 +21,7 @@ pub fn compute_between_dataframes( if let (UntaggedValue::DataFrame(lhs), UntaggedValue::DataFrame(rhs)) = (&left.value, &right.value) { - let operation_span = left.tag.span.until(right.tag.span); + let operation_span = right.tag.span.merge(left.tag.span); match (lhs.is_series(), rhs.is_series()) { (true, true) => { let lhs = &lhs diff --git a/crates/nu-source/src/meta.rs b/crates/nu-source/src/meta.rs index 6fb0fa10c..c2a4dda35 100644 --- a/crates/nu-source/src/meta.rs +++ b/crates/nu-source/src/meta.rs @@ -605,6 +605,16 @@ impl Span { Span::new(self.start, other.end) } + pub fn merge(&self, other: impl Into) -> Span { + let other = other.into(); + + if other.end < self.start { + other.until(self) + } else { + self.until(other) + } + } + /// Returns a new Span by merging a later Span with the current Span. /// /// If the given Span is of the None variant,