From 2f23d0dd1001d5790db5d1f1e03e1e2a1c0864f7 Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Sun, 5 Feb 2023 16:18:22 +0900 Subject: [PATCH] cli: specify ui.diff/merge-editor keys statically This helps me grep source code. --- src/merge_tools.rs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/merge_tools.rs b/src/merge_tools.rs index 490dff570..68c569b24 100644 --- a/src/merge_tools.rs +++ b/src/merge_tools.rs @@ -442,7 +442,7 @@ fn get_diff_editor_from_settings( ui: &mut Ui, settings: &UserSettings, ) -> Result { - 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 { - 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 { // 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) }