feat(compat-editor): Save As prompt when launched without a filename#56
Merged
Conversation
Pressing Ctrl-S with no filename was a silent no-op (g_filename == NULL). Add a minimal status-line 'Save as:' prompt: type a path, Enter saves and adopts the name, Esc (or empty) cancels. Reference the new static prompt_filename from the white-box test so -Werror -Wunused-function stays satisfied.
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.
Summary
The example editor's
Ctrl-Swas a silent no-op when launched without a filename (./editorwith no argument →g_filename == NULL→save_file()returned immediately). Add a minimal Save As prompt.Behavior
Ctrl-Swith no filename → aSave as:prompt on the status line. Type a path, Enter saves and adopts the name (subsequent saves go straight to it); Esc or an empty name cancels.Ctrl-Swith a filename (launched as./editor file.txt) → unchanged, saves in place.Notes
static prompt_filename()runs a small input loop using the editor's existingtb_*idiom; no new dependencies.-Werror -Wunused-functionbuild stays clean.Testing
ctest→ 100% passed, 37 tests.editor+test_compat_editorbuild clean under-Werroron gcc and clang (scalar lane);clang-formatclean.