From 8328fe926d34d12031cb50db47a9dd39ed681a84 Mon Sep 17 00:00:00 2001 From: Blaž Hrastnik Date: Tue, 23 Mar 2021 17:47:40 +0900 Subject: Drop refcell use, make view simply ref doc.id. --- helix-view/src/tree.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'helix-view/src/tree.rs') diff --git a/helix-view/src/tree.rs b/helix-view/src/tree.rs index 0a487b6f..e56566e3 100644 --- a/helix-view/src/tree.rs +++ b/helix-view/src/tree.rs @@ -164,7 +164,18 @@ impl Tree { self.recalculate() } - pub fn views(&mut self) -> impl Iterator { + pub fn views(&self) -> impl Iterator { + let focus = self.focus; + self.nodes.iter().filter_map(move |(key, node)| match node { + Node { + content: Content::View(view), + .. + } => Some((view.as_ref(), focus == key)), + _ => None, + }) + } + + pub fn views_mut(&mut self) -> impl Iterator { let focus = self.focus; self.nodes .iter_mut() @@ -231,7 +242,6 @@ impl Tree { Content::View(view) => { // debug!!("setting view area {:?}", area); view.area = area; - view.ensure_cursor_in_view(); } // TODO: call f() Content::Container(container) => { // debug!!("setting container area {:?}", area); -- cgit v1.2.3-70-g09d2