Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make diff line-break visualisation "¶" optional #1906

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ impl DiffComponent {

let content =
if !is_content_line && line.content.as_ref().is_empty() {
String::from(strings::symbol::LINE_BREAK)
theme.line_break()
} else {
tabs_to_spaces(line.content.as_ref().to_string())
};
Expand Down
1 change: 1 addition & 0 deletions src/strings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ pub mod symbol {
pub const SPACE: &str = "\u{02FD}"; //˽
pub const EMPTY_SPACE: &str = " ";
pub const LINE_BREAK: &str = "¶";
pub const NO_LINE_BREAK: &str = "";
pub const FOLDER_ICON_COLLAPSED: &str = "\u{25b8}"; //▸
pub const FOLDER_ICON_EXPANDED: &str = "\u{25be}"; //▾
pub const EMPTY_STR: &str = "";
Expand Down
11 changes: 11 additions & 0 deletions src/ui/style.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::strings;
use anyhow::Result;
use asyncgit::{DiffLineType, StatusItemType};
use ratatui::style::{Color, Modifier, Style};
Expand Down Expand Up @@ -32,6 +33,7 @@ pub struct Theme {
push_gauge_fg: Color,
tag_fg: Color,
branch_fg: Color,
line_break_visible: bool,
}

impl Theme {
Expand Down Expand Up @@ -263,6 +265,14 @@ impl Theme {
Style::default().fg(Color::Yellow)
}

pub fn line_break(&self) -> String {
if self.line_break_visible {
String::from(strings::symbol::LINE_BREAK)
} else {
String::from(strings::symbol::NO_LINE_BREAK)
}
}

fn load_patch(theme_path: &PathBuf) -> Result<ThemePatch> {
let file = File::open(theme_path)?;

Expand Down Expand Up @@ -336,6 +346,7 @@ impl Default for Theme {
push_gauge_fg: Color::Reset,
tag_fg: Color::LightMagenta,
branch_fg: Color::LightYellow,
line_break_visible: true,
}
}
}
Expand Down