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:
parent
39c0f0d2d5
commit
742df2758b
1 changed files with 21 additions and 21 deletions
|
@ -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::*;
|
||||
|
|
Loading…
Reference in a new issue