{"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/58e5313667b857ef39a730e380af31816a7b1768/crates/but/src/tui/get_text.rs#L140-L176","documentation":"from_builtin_editor launches the user's editor (via run_builtin_editor) to collect text. The editor returns an Option: None signals the user closed/aborted the editor without saving content. In that case from_editor bails with 'Editor cancelled' so the calling command can abort cleanly rather than treating it as empty text.","triggerScenarios":"Any flow that opens the editor for input (commit messages, feedback, notes) where the editor exits without producing content — e.g. saving an empty buffer, closing without saving, or the editor being killed.","commonSituations":"User changes their mind and quits the editor (:q! in vim, Ctrl-X without save in nano); terminal resized/killed mid-edit; GIT_EDITOR misconfigured to something that exits immediately.","solutions":["Re-run the command and save (non-empty) content in the editor this time.","Check `git var GIT_EDITOR` / EDITOR / VISUAL env vars if the editor exits unexpectedly.","Pass the text directly via flags/arguments instead of the editor when available, to bypass the editor flow."],"exampleFix":"// before (vim) :q!  -> Editor cancelled\n// after (vim) write and quit: :wq\n# or set a working editor\nexport EDITOR=vim","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match get_text::from_editor(...) {\n    Err(e) if e.to_string().contains(\"Editor cancelled\") => {\n        // treat as user abort: skip, don't error\n    }\n    other => other?,\n}","preventionTips":["Save non-empty content before closing the editor (:wq, Ctrl-O Ctrl-X)","Verify EDITOR/GIT_EDITOR/VISUAL point to a working editor","Provide non-editor flags for scripted usage"],"tags":["editor","tui","user-abort","cli"],"backgroundTag":"user-cancelled-operation","analyzedSha":"58e5313667b857ef39a730e380af31816a7b1768","analyzedAt":"2026-09-18T06:50:32.052Z","contentChangedAt":"2026-09-18T06:50:32.052Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}