Persist the default Git diff layout
This commit is contained in:
@@ -46,6 +46,25 @@ pub const GIT_DIFF_ALGORITHMS: [GitDiffAlgorithm; 3] = [
|
||||
GitDiffAlgorithm::Minimal,
|
||||
];
|
||||
|
||||
pub const GIT_DIFF_LAYOUTS: [GitDiffLayout; 2] = [GitDiffLayout::Unified, GitDiffLayout::Split];
|
||||
|
||||
#[derive(Clone, Copy, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
pub enum GitDiffLayout {
|
||||
#[default]
|
||||
Unified,
|
||||
Split,
|
||||
}
|
||||
|
||||
impl fmt::Display for GitDiffLayout {
|
||||
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
formatter.write_str(match self {
|
||||
Self::Unified => "1 column",
|
||||
Self::Split => "2 columns",
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
pub enum GitDiffAlgorithm {
|
||||
@@ -96,6 +115,7 @@ impl fmt::Display for GitDiffWhitespace {
|
||||
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
|
||||
#[serde(default, deny_unknown_fields)]
|
||||
pub struct GitConfig {
|
||||
pub diff_layout: GitDiffLayout,
|
||||
pub diff_algorithm: GitDiffAlgorithm,
|
||||
pub context_lines: u32,
|
||||
pub interhunk_lines: u32,
|
||||
@@ -107,6 +127,7 @@ pub struct GitConfig {
|
||||
impl Default for GitConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
diff_layout: GitDiffLayout::Unified,
|
||||
diff_algorithm: GitDiffAlgorithm::Default,
|
||||
context_lines: 3,
|
||||
interhunk_lines: 0,
|
||||
@@ -282,6 +303,7 @@ mod tests {
|
||||
..RuntimePreferences::default()
|
||||
},
|
||||
git: GitConfig {
|
||||
diff_layout: GitDiffLayout::Split,
|
||||
diff_algorithm: GitDiffAlgorithm::Patience,
|
||||
context_lines: 5,
|
||||
whitespace: GitDiffWhitespace::IgnoreEndOfLine,
|
||||
@@ -297,7 +319,7 @@ mod tests {
|
||||
"model: glm-5.2\na2ui_enabled: false\n\
|
||||
generation:\n context_tokens: 65536\n reasoning_mode: none\n\
|
||||
runtime:\n ssd:\n enabled: true\n cache: 64GB\n\
|
||||
git:\n diff_algorithm: patience\n context_lines: 5\n whitespace: ignore-end-of-line\n"
|
||||
git:\n diff_layout: split\n diff_algorithm: patience\n context_lines: 5\n whitespace: ignore-end-of-line\n"
|
||||
);
|
||||
assert_eq!(Config::load(&path).unwrap(), config);
|
||||
fs::remove_dir_all(&directory).unwrap();
|
||||
|
||||
Reference in New Issue
Block a user