Skip to content

Keep the editor's unsaved and on-disk questions readable for long paths - #545

Draft
raiseCatError wants to merge 1 commit into
devfrom
fix/editor-dialog-long-path
Draft

raiseCatError wants to merge 1 commit into
devfrom
fix/editor-dialog-long-path

Conversation

@raiseCatError

Copy link
Copy Markdown
Owner

What changed

The editor's dialog cut its whole message from the right to fit the panel. When the file's shown path was long, the user lost the question itself. In an 80-column panel, a path of about 57 characters or more turned "has unsaved changes." into "has unsaved chang…" or hid it completely. The same happened to "changed on disk since you opened it."

When a dialog message starts with the file's path and doesn't fit, fitFileMessage in src/viewer/EditorPanel.ts now shortens the path from the left. The file name and the rest of the sentence stay whole, for example …/nmsh-edit-Tu2zes/b.txt has unsaved changes. Messages that fit, messages that don't start with the path, and very narrow panels behave as before.

Why

This came out of investigating four tests that fail locally on pristine dev (c690de0) but pass in hosted CI. panel: Esc with unsaved changes asks; … failed on this Mac only because NMSH_TEST_TMPDIR gave a 34-character temp root instead of CI's short one. That pushed the test file's path past the limit. The test was right; the rendering was wrong for any long path. The other three failures are environmental (no LANG locale, and a temp root over the runner's 32-character limit), so this PR doesn't change them.

Tests

  • New: panel: a long file path gives way from the left, so the unsaved and on-disk questions stay readable. It uses a deliberately long folder name, so it doesn't depend on the temp path. It fails without the fix and passes with it.
  • tests/textEditor.test.ts passes in full (14/14) with both a 31-character and a long temp root. Before the fix the existing Esc test failed 3/3 with the long root.
  • tsc --noEmit and git diff --check are clean.
  • Full local npm run verify (with LANG=en_US.UTF-8 and a short root): 4500 passed, 71 failed. All 71 are live-frontend timeouts that ran while load averages reached 65, with other sessions running suites on the same 8 GB Mac. 58 of the frontends they report on had printed 0 bytes after 20 s while still alive, so they never got through startup. Two of the failing files, ctrlZJobControl and the sessionPresets startup test, pass on their own. None of them touch the editor panel. Hosted CI is the independent gate here.

Needs human testing

This was checked against rendered rows, not in a terminal. To try it in a real terminal (Ghostty or Terminal.app at about 80 columns): run /edit on a file with a long path, type a character, then press Esc. The question should read …<end of path>/file has unsaved changes. with Save / Discard changes / Keep editing below it.

The editor dialog cut its whole message from the right, so a file whose
shown path was longer than the panel lost 'has unsaved changes.' or
'changed on disk'. When the message starts with the file's path, the
path now gives way from the left and keeps its file name.

This also explains why the existing Esc dialog test failed locally when
NMSH_TEST_TMPDIR gave a longer temp root than CI's.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant