Repository navigation
Native /edit: a small, safe editor for one text file (#402) - #414
Merged
Merged
Conversation
/edit <path> (or e in /view) opens one small text file in a full-height panel: typing, multi-line, caret by character/word/line/page, Shift selection, Ctrl+Z/Ctrl+Y undo and redo (bounded, coalesced), Ctrl+F find, Ctrl+C/Ctrl+X copy and cut, Ctrl+S save, Esc closes and asks about unsaved changes. Ctrl+Y now decodes as redo (it was dropped before). Only files that can be saved back exactly are opened: regular UTF-8 text up to 1 MiB, owned by this user, one hard link, writable file and folder, one kind of line ending (BOM and final newline kept); a missing path in a writable folder opens empty. Saving writes beside the original (exclusive create, its mode and group), syncs, re-checks that the original is still the file opened (device, inode, size, time, content hash) and renames over its real path; a symlink stays a symlink. A changed, replaced or deleted original is a conflict: Keep editing, Overwrite, or Reload. A new file never replaces one that appeared meanwhile.
This was referenced Oct 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #413 (
/view) → #412 → #411. Merge in order.What
/edit <path>, orein/viewon a file, opens one small text file in a full-height panel. It owns keys only while open; the composer draft and the shell are untouched.redo; it was dropped before, and the composer still ignores it.src/ui/actionControls.tsrenderer (Terminal-native action controls: reusable styles, semantic states and safe fallbacks #336). Unsaved changes: Save / Discard changes / Keep editing. Conflicts: Keep editing / Overwrite / Reload. The destructive choice is marked without relying on color.Saving safely (
src/viewer/fileEdit.ts)/view.link(), which fails rather than replaces if something appeared meanwhile.0600, then the original's mode and group (best effort).fsync.renameover its real path, so a symlink stays a symlink.Tests
textEditor.test.ts, 12 tests:viewerApp.test.ts:/edit→ type → Ctrl+S saves → Esc closes;efrom/view; a refused binary is reported.viewerLive.test.ts: a real PTY creates a file through/edit; typed text and a real Ctrl+S byte save it; Esc returns to the composer.Not verified
Physical terminal checks are in
docs/testing/v021-physical-qa.md, section 3, and have not been run.Known limitation: unsaved text is lost if the NMSh window itself is closed.
Refs #402, #336, #410