aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPeter Geissler <peter@haxx.in>2026-08-28 13:25:19 +0200
committerPeter Geissler <peter@haxx.in>2026-08-28 13:25:19 +0200
commita1388560b2adfc7a3ec98438b4183710d4f466e2 (patch)
treec8f766f459efe78c4fb53d0a2a54f7f882c2f37c /src
parentdocs: the Windows port, and what is different there (diff)
downloadslosh-a1388560b2adfc7a3ec98438b4183710d4f466e2.tar.gz
slosh-a1388560b2adfc7a3ec98438b4183710d4f466e2.tar.xz
slosh-a1388560b2adfc7a3ec98438b4183710d4f466e2.zip
windows: fall back to `edit`, not to a notepad window
`C-a e` on a Windows with no editor installed opened notepad, which is a GUI program: the pane it was spawned in drew nothing, so the split sat there empty while the config opened in a window somewhere else. The toast said as much, but a pane you have to be told to ignore is still the wrong answer. Windows 11 24H2 ships Microsoft Edit as `edit`, and it is a console program -- it fills the pane like nvim or nano would, so the fallback now has the same shape as the thing it is falling back from, and a first-time user gets a usable editor without installing one. It goes last of the console editors rather than first. Having fetched nvim is a statement of preference; having been shipped `edit` says nothing about what you want, so anything you chose yourself outranks it. notepad stays behind it: `edit` is not on Windows 10, or on 11 before 24H2, and something that opens is better than nothing when the alternative is an empty pane. sl_which() already tries .exe, so it is found as installed; the search still only runs when neither EDITOR nor the config asked for anything.
Diffstat (limited to 'src')
-rw-r--r--src/app_layout.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/app_layout.c b/src/app_layout.c
index 59a00d7..5910b52 100644
--- a/src/app_layout.c
+++ b/src/app_layout.c
@@ -1511,15 +1511,26 @@ bool app_edit_config(app_t *a) {
/* Windows has no editor it is *required* to have, and the obvious fallback
* is the wrong shape: notepad is a GUI program, so a pane running it draws
* nothing and looks broken. Prefer whichever console editor is actually
- * installed, and only then fall back to opening a window.
+ * installed -- including `edit`, which recent Windows ships itself -- and
+ * only then fall back to opening a window.
*
* `editor` here is still whatever EDITOR or the config asked for; the search
* only runs when nothing was asked for, or when the POSIX default of `vi`
* came through and would not exist. */
bool windowed = false;
if (!editor || !*editor || strcmp(editor, "vi") == 0) {
- static const char *const consoles[] = {"nvim", "vim", "vi", "nano",
- "micro", "hx", NULL};
+ /* Editors somebody chose to install come first: having fetched nvim is a
+ * statement of preference, and Windows' own editor is not. `edit` --
+ * Microsoft Edit -- is last of the console editors because it is the one
+ * that arrives on its own, and so says nothing about what you want.
+ *
+ * It is still much the better fallback: it is a console program, so it
+ * fills the pane like any other editor, and a first-time user gets
+ * something usable without installing anything. It only ships from
+ * Windows 11 24H2 onwards, though, which is why notepad remains behind
+ * it rather than being replaced by it. */
+ static const char *const consoles[] = {"nvim", "vim", "vi", "nano",
+ "micro", "hx", "edit", NULL};
editor = NULL;
for (int i = 0; consoles[i] && !editor; i++)
if (sl_which(consoles[i])) editor = consoles[i];