{"record":{"id":"82a7702631ca9d81","repo":"gitbutlerapp/gitbutler","slug":"editor-cancelled","errorCode":null,"errorMessage":"Editor cancelled","messagePattern":"Editor cancelled","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/but/src/tui/get_text.rs","lineNumber":158,"sourceCode":"    } else {\n        super::editor::EditorMode::PullRequest\n    };\n\n    let editor_output = if let Some(rest_text) = rest_text {\n        let mut initial_text = initial_text.to_owned();\n        if !initial_text.ends_with('\\n') {\n            initial_text.push('\\n');\n        }\n        initial_text.push_str(REST_TEXT_MARKER);\n        initial_text.push('\\n');\n        initial_text.push_str(rest_text);\n        super::editor::run_builtin_editor(filename_safe_intent, &initial_text, mode)?\n    } else {\n        super::editor::run_builtin_editor(filename_safe_intent, initial_text, mode)?\n    };\n    match editor_output {\n        Some(content) => Ok(content.into()),\n        None => bail!(\"Editor cancelled\"),\n    }\n}\n\n/// Get the user's preferred editor command, if one is configured.\n///\n/// Runs `git var GIT_EDITOR`, which lets git do its resolution of the editor command.\n/// This typically uses the git config value for `core.editor`, and env vars like `GIT_EDITOR` or `EDITOR`.\n///\n/// Returns `None` when no editor is configured, signalling that the built-in editor should be used.\n///\n/// Note: Because git config parsing is used, the current directory matters for potential local git config overrides.\npub fn get_editor_command() -> Option<String> {\n    get_editor_command_impl(std::env::vars_os())\n}\n\n/// Internal implementation that can be tested with the controlled environment `env`.\n///\n/// Checks the standard Git editor sources in precedence order:","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/caf1f223d3cfb94488c9198ad34487c6006c648f/crates/but/src/tui/get_text.rs#L140-L176","documentation":"The built-in TUI editor signals cancellation by returning None from run_builtin_editor; from_editor maps that to this error. It means the user deliberately aborted the input (quit without confirming text) - a normal outcome of an interactive edit, not an editor or system failure.","triggerScenarios":"The user exits the builtin editor without confirming - pressing the quit/abort key (Esc/Ctrl-C depending on mode) or ending the session without content, so editor_output is None.","commonSituations":"Users aborting commit-message or branch-description prompts, scripts treating every non-zero exit as a bug, non-interactive test harnesses where the editor immediately cancels.","solutions":["Treat it as a user abort: skip the operation or re-prompt; do not auto-retry the same edit","In automation, supply the text non-interactively instead of opening an editor","If cancellation surprises the user, check keybindings for accidental Esc/Ctrl-C"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match from_editor(\"msg\", &text, None, \".md\") {\n    Ok(edited) => { /* proceed */ }\n    Err(e) if e.to_string() == \"Editor cancelled\" => { /* user abort: exit quietly */ }\n    Err(e) => return Err(e),\n}","preventionTips":["Match the cancellation message and treat it as a normal abort path","Offer non-interactive flags (--message/--file) so automation never opens an editor","Map cancellation to a distinct exit code in wrappers (e.g. 130-style)"],"tags":["tui","editor","user-cancellation","input"],"backgroundTag":"user-cancelled-input","analyzedSha":"caf1f223d3cfb94488c9198ad34487c6006c648f","analyzedAt":"2026-08-20T07:55:40.983Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}