diff options
author | Blaž Hrastnik | 2021-03-23 08:47:40 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2021-03-23 09:14:35 +0000 |
commit | 8328fe926d34d12031cb50db47a9dd39ed681a84 (patch) | |
tree | acea128c5a3c2276f7ad553666a6572a5ba7d62d /helix-view/src/tree.rs | |
parent | 3f9a94fd4364fe277f11668b0bfab4f2735c4daf (diff) |
Drop refcell use, make view simply ref doc.id.
Diffstat (limited to 'helix-view/src/tree.rs')
-rw-r--r-- | helix-view/src/tree.rs | 14 |
1 files changed, 12 insertions, 2 deletions
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<Item = (&mut View, bool)> { + pub fn views(&self) -> impl Iterator<Item = (&View, bool)> { + 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<Item = (&mut View, bool)> { 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); |