ok/jj
1
0
Fork 0
forked from mirrors/jj

merge_tools: reorder editor_args_from_settings

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.
This commit is contained in:
Waleed Khan 2023-08-29 23:13:36 +02:00
parent 39c0f0d2d5
commit 742df2758b

View file

@ -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,
@ -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::*;