aboutsummaryrefslogtreecommitdiffstats
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
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.
-rw-r--r--docs/windows.md15
-rw-r--r--src/app_layout.c17
2 files changed, 24 insertions, 8 deletions
diff --git a/docs/windows.md b/docs/windows.md
index 9e1975f..12b4a8c 100644
--- a/docs/windows.md
+++ b/docs/windows.md
@@ -126,10 +126,15 @@ the session on the one program that misbehaves. Whoever finishes last frees.
full argv without reading another process's memory, so pane titles are
correspondingly shorter.
- **No editor is guaranteed.** `C-a e` prefers whichever console editor is
- actually installed — `nvim`, `vim`, `vi`, `nano`, `micro`, `hx` — because the
- obvious fallback is the wrong shape: `notepad` is a GUI program, so a pane
- running it draws nothing and looks broken. If none is found it still opens
- notepad, and says so, rather than leaving you an empty pane to puzzle over.
- `EDITOR` and the config's `editor` are honoured ahead of the search.
+ actually installed — `nvim`, `vim`, `vi`, `nano`, `micro`, `hx`, `edit` —
+ because the obvious fallback is the wrong shape: `notepad` is a GUI program,
+ so a pane running it draws nothing and looks broken. Microsoft Edit (`edit`)
+ is a console program, so it fills a pane like any other editor: from Windows
+ 11 24H2 there is a usable editor without installing one. It comes last of the
+ console editors because it arrives on its own, and so says nothing about what
+ you want, where having fetched nvim does. Older Windows does not ship it, so
+ if nothing is found slosh still opens notepad, and says so, rather than
+ leaving you an empty pane to puzzle over. `EDITOR` and the config's `editor`
+ are honoured ahead of the search.
- **`--check`, `--dump-config`, layouts, workspaces and shaders** are
unaffected: they never touched a pty or a socket.
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];