From 68994248ee31adb11a0d5844c92620b89ae5bc09 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Wed, 2 Jun 2021 17:47:25 -0700 Subject: [PATCH] Add custom error message for rope cursor slice precondition --- zed/src/editor/buffer/rope.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/zed/src/editor/buffer/rope.rs b/zed/src/editor/buffer/rope.rs index 05b30e3896..1b5d8fb896 100644 --- a/zed/src/editor/buffer/rope.rs +++ b/zed/src/editor/buffer/rope.rs @@ -213,7 +213,12 @@ impl<'a> Cursor<'a> { } pub fn slice(&mut self, end_offset: usize) -> Rope { - debug_assert!(end_offset >= self.offset); + debug_assert!( + end_offset >= self.offset, + "cannot slice backwards from {} to {}", + self.offset, + end_offset + ); let mut slice = Rope::new(); if let Some(start_chunk) = self.chunks.item() {