Skip to content

Commit

Permalink
merge_tools: reorder editor_args_from_settings
Browse files Browse the repository at this point in the history
  • Loading branch information
arxanas committed Aug 22, 2023
1 parent 18b3d7a commit aa8f576
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions cli/src/merge_tools/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,27 @@ pub fn get_tool_config(
}
}

/// Finds the appropriate tool for diff editing or merges
fn editor_args_from_settings(
ui: &Ui,
settings: &UserSettings,
key: &str,
) -> Result<CommandNameAndArgs, ExternalToolError> {
// TODO: Make this configuration have a table of possible editors and detect the
// best one here.
if let Some(args) = settings.config().get(key).optional()? {
Ok(args)
} else {
let default_editor = "meld";
writeln!(
ui.hint(),
"Using default editor '{default_editor}'; you can change this by setting {key}"
)
.map_err(ExternalToolError::Io)?;
Ok(default_editor.into())
}
}

/// Loads merge tool options from `[merge-tools.<name>]` if `args` is of
/// unstructured string type.
pub fn get_tool_config_from_args(
Expand Down Expand Up @@ -218,27 +239,6 @@ fn get_merge_tool_from_settings(
}
}

/// Finds the appropriate tool for diff editing or merges
fn editor_args_from_settings(
ui: &Ui,
settings: &UserSettings,
key: &str,
) -> Result<CommandNameAndArgs, ExternalToolError> {
// TODO: Make this configuration have a table of possible editors and detect the
// best one here.
if let Some(args) = settings.config().get(key).optional()? {
Ok(args)
} else {
let default_editor = "meld";
writeln!(
ui.hint(),
"Using default editor '{default_editor}'; you can change this by setting {key}"
)
.map_err(ExternalToolError::Io)?;
Ok(default_editor.into())
}
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down

0 comments on commit aa8f576

Please sign in to comment.