Skip to content

Commit

Permalink
merge_tools: reorder editor_args_from_settings
Browse files Browse the repository at this point in the history
The rest of the functions in this file are defined before they are used, so it confused me when trying to track down this function in the static call graph.
  • Loading branch information
arxanas committed Sep 19, 2023
1 parent 39c0f0d commit 742df27
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 @@ -155,6 +155,27 @@ pub enum MergeTool {
External(ExternalMergeTool),
}

/// 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>]`.
pub fn get_tool_config(
settings: &UserSettings,
Expand Down Expand Up @@ -216,27 +237,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 742df27

Please sign in to comment.