mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-15 16:53:25 +00:00
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,
|
ui: &mut Ui,
|
||||||
settings: &UserSettings,
|
settings: &UserSettings,
|
||||||
) -> Result<MergeTool, ExternalToolError> {
|
) -> 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)?)
|
Ok(get_tool_config(settings, &editor_name)?)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -450,7 +450,7 @@ fn get_merge_tool_from_settings(
|
||||||
ui: &mut Ui,
|
ui: &mut Ui,
|
||||||
settings: &UserSettings,
|
settings: &UserSettings,
|
||||||
) -> Result<MergeTool, ConflictResolveError> {
|
) -> 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)?;
|
let editor = get_tool_config(settings, &editor_name).map_err(ExternalToolError::ConfigError)?;
|
||||||
if editor.merge_args.is_empty() {
|
if editor.merge_args.is_empty() {
|
||||||
Err(ConflictResolveError::MergeArgsNotConfigured {
|
Err(ConflictResolveError::MergeArgsNotConfigured {
|
||||||
|
@ -465,21 +465,17 @@ fn get_merge_tool_from_settings(
|
||||||
fn editor_name_from_settings(
|
fn editor_name_from_settings(
|
||||||
ui: &mut Ui,
|
ui: &mut Ui,
|
||||||
settings: &UserSettings,
|
settings: &UserSettings,
|
||||||
diff_or_merge: &str,
|
key: &str,
|
||||||
) -> Result<String, ExternalToolError> {
|
) -> Result<String, ExternalToolError> {
|
||||||
// TODO: Make this configuration have a table of possible editors and detect the
|
// TODO: Make this configuration have a table of possible editors and detect the
|
||||||
// best one here.
|
// best one here.
|
||||||
match settings
|
match settings.config().get_string(key) {
|
||||||
.config()
|
|
||||||
.get_string(&format!("ui.{diff_or_merge}-editor"))
|
|
||||||
{
|
|
||||||
Ok(editor_binary) => Ok(editor_binary),
|
Ok(editor_binary) => Ok(editor_binary),
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
let default_editor = "meld".to_string();
|
let default_editor = "meld".to_string();
|
||||||
writeln!(
|
writeln!(
|
||||||
ui.hint(),
|
ui.hint(),
|
||||||
"Using default editor '{default_editor}'; you can change this by setting \
|
"Using default editor '{default_editor}'; you can change this by setting {key}"
|
||||||
ui.{diff_or_merge}-editor"
|
|
||||||
)?;
|
)?;
|
||||||
Ok(default_editor)
|
Ok(default_editor)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue