Skip to content

Commit

Permalink
Fix: mode sep hybrid presents and abitrary, only show when visible
Browse files Browse the repository at this point in the history
  • Loading branch information
0xrsp committed Dec 9, 2022
1 parent cf679f0 commit 1c2b828
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 33 deletions.
45 changes: 23 additions & 22 deletions helix-term/src/ui/statusline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use helix_view::{

use crate::ui::ProgressSpinners;

use helix_view::editor::ModeSeparator;
use helix_view::editor::StatusLineElement as StatusLineElementID;
use tui::buffer::Buffer as Surface;
use tui::text::{Span, Spans};
Expand Down Expand Up @@ -192,27 +191,29 @@ where
mode_style,
);

match config.statusline.mode_separator {
ModeSeparator::Flat => {}
_ => {
// use mode style as mode separator style except set
// background to statusline background
let mode_separator_style = mode_style.map(|s| Style {
fg: s.bg,
bg: context.editor.theme.get("ui.statusline").bg,
..Default::default()
});

let mode_separator = match config.statusline.mode_separator {
ModeSeparator::Angled => "",
ModeSeparator::Slanted => "",
ModeSeparator::Round => "",
ModeSeparator::Flat => unreachable!(),
};

write(context, mode_separator.to_string(), mode_separator_style);
}
};
if visible {
match config.statusline.mode_separator.as_str() {
"" => {}
_ => {
// use mode style as mode separator style except set
// background to statusline background
let mode_separator_style = mode_style.map(|s| Style {
fg: s.bg,
bg: context.editor.theme.get("ui.statusline").bg,
..Default::default()
});

let mode_separator = match config.statusline.mode_separator.as_str() {
"angled" => "",
"slanted" => "",
"round" => "",
s => s,
};

write(context, mode_separator.to_string(), mode_separator_style);
}
};
}
}

fn render_lsp_spinner<F>(context: &mut RenderContext, write: F)
Expand Down
13 changes: 2 additions & 11 deletions helix-view/src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,16 +271,7 @@ pub struct StatusLineConfig {
pub right: Vec<StatusLineElement>,
pub separator: String,
pub mode: ModeConfig,
pub mode_separator: ModeSeparator,
}

#[derive(Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
pub enum ModeSeparator {
Flat,
Angled,
Round,
Slanted,
pub mode_separator: String,
}

impl Default for StatusLineConfig {
Expand All @@ -293,7 +284,7 @@ impl Default for StatusLineConfig {
right: vec![E::Diagnostics, E::Selections, E::Position, E::FileEncoding],
separator: String::from("│"),
mode: ModeConfig::default(),
mode_separator: ModeSeparator::Flat,
mode_separator: String::from(""),
}
}
}
Expand Down

0 comments on commit 1c2b828

Please sign in to comment.