forked from mirrors/jj
cli: specify ui.diff/merge-editor keys statically
This helps me grep source code.
This commit is contained in:
parent
0163bba347
commit
2f23d0dd10
1 changed files with 5 additions and 9 deletions
|
@ -442,7 +442,7 @@ fn get_diff_editor_from_settings(
|
|||
ui: &mut Ui,
|
||||
settings: &UserSettings,
|
||||
) -> Result<MergeTool, ExternalToolError> {
|
||||
let editor_name = editor_name_from_settings(ui, settings, "diff")?;
|
||||
let editor_name = editor_name_from_settings(ui, settings, "ui.diff-editor")?;
|
||||
Ok(get_tool_config(settings, &editor_name)?)
|
||||
}
|
||||
|
||||
|
@ -450,7 +450,7 @@ fn get_merge_tool_from_settings(
|
|||
ui: &mut Ui,
|
||||
settings: &UserSettings,
|
||||
) -> Result<MergeTool, ConflictResolveError> {
|
||||
let editor_name = editor_name_from_settings(ui, settings, "merge")?;
|
||||
let editor_name = editor_name_from_settings(ui, settings, "ui.merge-editor")?;
|
||||
let editor = get_tool_config(settings, &editor_name).map_err(ExternalToolError::ConfigError)?;
|
||||
if editor.merge_args.is_empty() {
|
||||
Err(ConflictResolveError::MergeArgsNotConfigured {
|
||||
|
@ -465,21 +465,17 @@ fn get_merge_tool_from_settings(
|
|||
fn editor_name_from_settings(
|
||||
ui: &mut Ui,
|
||||
settings: &UserSettings,
|
||||
diff_or_merge: &str,
|
||||
key: &str,
|
||||
) -> Result<String, ExternalToolError> {
|
||||
// TODO: Make this configuration have a table of possible editors and detect the
|
||||
// best one here.
|
||||
match settings
|
||||
.config()
|
||||
.get_string(&format!("ui.{diff_or_merge}-editor"))
|
||||
{
|
||||
match settings.config().get_string(key) {
|
||||
Ok(editor_binary) => Ok(editor_binary),
|
||||
Err(_) => {
|
||||
let default_editor = "meld".to_string();
|
||||
writeln!(
|
||||
ui.hint(),
|
||||
"Using default editor '{default_editor}'; you can change this by setting \
|
||||
ui.{diff_or_merge}-editor"
|
||||
"Using default editor '{default_editor}'; you can change this by setting {key}"
|
||||
)?;
|
||||
Ok(default_editor)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue