From 9c15d4faded949a409edbd1fb3d4b6c4ebf30792 Mon Sep 17 00:00:00 2001 From: Igor Cohanovschi Date: Sun, 17 Jul 2022 18:06:05 +0200 Subject: [PATCH] Removed unused fields. Renamed style names to be in line with other ui.editor styles --- helix-term/src/ui/explore.rs | 4 ++-- helix-term/src/ui/tree.rs | 15 +++++---------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/helix-term/src/ui/explore.rs b/helix-term/src/ui/explore.rs index d0739ca0..8b4f6437 100644 --- a/helix-term/src/ui/explore.rs +++ b/helix-term/src/ui/explore.rs @@ -499,7 +499,7 @@ impl Explorer { )); } - fn fold_current(item: &mut FileInfo, cx: &mut Context, state: &mut State) { + fn fold_current(item: &mut FileInfo, _cx: &mut Context, _state: &mut State) { if item.path.is_dir() { item.expanded = false; } @@ -590,7 +590,7 @@ impl Explorer { let preview_area = area.clip_left(side_area.width).clip_bottom(2); let prompt_area = area.clip_top(side_area.height); - let border_style = cx.editor.theme.get("ui.explore.border"); + let border_style = cx.editor.theme.get("ui.explorer.border"); let list_area = render_block( side_area.clip_left(1), surface, diff --git a/helix-term/src/ui/tree.rs b/helix-term/src/ui/tree.rs index 6945bb38..711c3c2a 100644 --- a/helix-term/src/ui/tree.rs +++ b/helix-term/src/ui/tree.rs @@ -118,14 +118,12 @@ pub enum TreeOp { pub struct Elem { item: T, level: usize, - expanded: bool, folded: Vec, } impl Clone for Elem { fn clone(&self) -> Self { Self { - expanded: false, item: self.item.clone(), level: self.level, folded: self.folded.clone(), @@ -138,7 +136,6 @@ impl Elem { Self { item, level, - expanded: false, folded: vec![], } } @@ -180,7 +177,7 @@ impl Tree { col: 0, max_len: 0, count: 0, - tree_symbol_style: "ui.explore.guide".into(), + tree_symbol_style: "ui.explorer.guide".into(), pre_render: None, on_opened_fn: None, on_folded_fn: None, @@ -474,7 +471,6 @@ impl Tree { self.max_len = 0; self.row = std::cmp::min(self.row, area.height.saturating_sub(1) as usize); let style = cx.editor.theme.get(&self.tree_symbol_style); - let line_style = cx.editor.theme.get("ui.virtual.ruler"); let folder_style = cx.editor.theme.get("special"); let last_item_index = self.items.len().saturating_sub(1); let skip = self.selected.saturating_sub(self.row); @@ -490,10 +486,8 @@ impl Tree { let mut area = Rect::new(area.x, area.y + row, area.width, 1); let indent = if elem.level > 0 { if index + skip != last_item_index { - //format!("{}├─", "│ ".repeat(elem.level - 1)) format!("{}", "│ ".repeat(elem.level - 1)) } else { - //format!("└─{}", "┴─".repeat(elem.level - 1)) format!("{}", "".repeat(elem.level - 1)) } } else { @@ -516,13 +510,14 @@ impl Tree { return; } if start_index == 0 { - //let expanded = elem.folded.len() > 0; + let mut icon_offset = 0; if let Some((icon, color)) = elem.item.icon() { let style = folder_style.fg(*color); surface.set_string(area.x, area.y, icon, style); + icon_offset = 2; } - surface.set_span(area.x + 2, area.y, span, area.width - 2); - area = area.clip_left((span.width() - 2) as u16); + surface.set_span(area.x + icon_offset, area.y, span, area.width - icon_offset); + area = area.clip_left((span.width() - icon_offset as usize) as u16); } else { let span_width = span.width(); if start_index > span_width {