From e7a813b3837323335b96c0f83d328a135ae85a68 Mon Sep 17 00:00:00 2001 From: Alexandre Bury Date: Wed, 26 Aug 2020 16:44:56 -0700 Subject: [PATCH] Fix chunk_iterator with empty spans after hard-stop --- cursive-core/src/utils/lines/spans/chunk_iterator.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cursive-core/src/utils/lines/spans/chunk_iterator.rs b/cursive-core/src/utils/lines/spans/chunk_iterator.rs index 995e457..33e51a2 100644 --- a/cursive-core/src/utils/lines/spans/chunk_iterator.rs +++ b/cursive-core/src/utils/lines/spans/chunk_iterator.rs @@ -96,8 +96,8 @@ where // We need to check if the last segment ended with a space. // TODO: skip empty spans when going back - let prev_span = - self.source.spans()[self.current_span - 1].as_ref(); + let prev_span_id = segments.last().unwrap().span_id; + let prev_span = self.source.spans()[prev_span_id].as_ref(); let prev_text = prev_span.resolve(self.source.source()); if hard_stop {