feat: dim whitespace markers and configure scope and newlines

This commit is contained in:
2026-10-13 23:18:39 +02:00
parent adcc4f2656
commit 11b31d2621
10 changed files with 964 additions and 112 deletions
+18
View File
@@ -25,6 +25,14 @@ use unicode_width::UnicodeWidthStr;
const MAX_EDIT_BYTES: usize = 4 * 1024 * 1024;
static TEMP_ID: AtomicU64 = AtomicU64::new(0);
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, serde::Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum WhitespaceScope {
#[default]
All,
Leading,
}
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
pub enum Input {
Char(char),
@@ -1765,6 +1773,7 @@ pub struct Editor {
scroll_distance: Option<usize>,
highlight_trailing_whitespace: bool,
whitespace_characters: BTreeMap<char, char>,
whitespace_scope: WhitespaceScope,
battery_charge: Option<u8>,
battery_label: String,
git_blame: bool,
@@ -1869,6 +1878,7 @@ impl Editor {
scroll_distance: Some(0),
highlight_trailing_whitespace: false,
whitespace_characters: BTreeMap::new(),
whitespace_scope: WhitespaceScope::All,
battery_charge: None,
battery_label: String::new(),
git_blame: true,
@@ -2631,6 +2641,14 @@ impl Editor {
self.whitespace_characters = characters;
}
pub(crate) fn whitespace_scope(&self) -> WhitespaceScope {
self.whitespace_scope
}
pub(crate) fn set_whitespace_scope(&mut self, scope: WhitespaceScope) {
self.whitespace_scope = scope;
}
pub(crate) fn set_diff_context_options(&mut self, context_lines: usize, expand_lines: usize) {
self.diff_context_options = (context_lines, expand_lines);
if let Some(diff) = &mut self.diff {