From e2c19d3d3f5f84f748ee0ce0d50ff7538405135f Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Fri, 14 May 2021 15:19:03 +0200 Subject: [PATCH] Add `Rope::chunks` --- zed/src/editor/buffer/rope.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/zed/src/editor/buffer/rope.rs b/zed/src/editor/buffer/rope.rs index 63ca0ca66b..19e4178c39 100644 --- a/zed/src/editor/buffer/rope.rs +++ b/zed/src/editor/buffer/rope.rs @@ -138,6 +138,10 @@ impl Rope { Chars::new(self, start) } + pub fn chunks<'a>(&'a self) -> impl Iterator { + self.chunks.cursor::<(), ()>().map(|c| c.0.as_str()) + } + fn text(&self) -> String { let mut text = String::new(); for chunk in self.chunks.cursor::<(), ()>() {