Radish alpha
h
rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5
Radicle Heartwood Protocol & Stack
Radicle
Git
term/editor: add support for RAD_EDITOR
Open did:key:z6MksGpP...MGuV opened 1 month ago

This change adds support for determining the editor that should be opened by the RAD_EDITOR environment variable, which takes priority over both VISUAL and EDITOR, as it is specific to the radicle application.

This enables users to set a different editor specifically for radicle, which is useful in the event that the normal value for either VISUAL or EDITOR is a process that forks and exits early, but supports command line flags to modify this behavior and block on the main thread (e.g. neovim-remote, which the author uses).

1 file changed +6 -2 7bac1714 07a6c815
modified crates/radicle-term/src/editor.rs
@@ -107,7 +107,7 @@ impl Editor {
        let Some(cmd) = self::default_editor() else {
            return Err(io::Error::new(
                io::ErrorKind::NotFound,
-
                "editor not configured: the `EDITOR` environment variable is not set",
+
                "editor not configured: please set `RAD_EDITOR`, `VISUAL`, or `EDITOR` to resolve",
            ));
        };

@@ -200,7 +200,11 @@ impl Editor {

/// Get the default editor command.
fn default_editor() -> Option<OsString> {
-
    // First check the standard environment variables.
+
    if let Ok(rad_editor) = env::var("RAD_EDITOR") {
+
        if !rad_editor.is_empty() {
+
            return Some(rad_editor.into());
+
        }
+
    }
    if let Ok(visual) = env::var("VISUAL") {
        if !visual.is_empty() {
            return Some(visual.into());