diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c6b4ff..ac4dd73 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ for details * Resolve crash when user tries to switch top or bottom line outside of scope * Resolved crash when the user tries to `delete word` past the end of a line +* Resolved defect that allowed unnamed buffers to be saved as `NO NAME` ### v0.0.3 | 17/Mar/2026 * Use `;e` to open a different file from within iris diff --git a/src/controller.cpp b/src/controller.cpp index 8f10763..ab3fb01 100644 --- a/src/controller.cpp +++ b/src/controller.cpp @@ -620,8 +620,10 @@ bool Controller::parse_command() { } else if (cmd == ";wq") { // This just does the same as ;w and ;q - std::ignore = write_to_file(view.get_active_model(), std::nullopt); - return quit_app(false); + WriteData data = write_to_file(view.get_active_model(), std::nullopt); + if (data.valid) { return quit_app(false); } + view.display_message("Could not save file: no filename specified", rawterm::Colors::red); + return false; } else if (cmd == ";wa") { WriteAllData write_data = write_all(); @@ -644,6 +646,9 @@ bool Controller::parse_command() { std::string msg = std::format("Saved {} bytes ({} lines)", file_write.bytes, file_write.lines); view.display_message(msg, rawterm::Colors::green); + } else { + view.display_message( + "Could not save file: no filename specified", rawterm::Colors::red); } } else if (cmd == ";qa") { diff --git a/src/text_io.cpp b/src/text_io.cpp index a56a076..c9bcd2a 100644 --- a/src/text_io.cpp +++ b/src/text_io.cpp @@ -57,8 +57,9 @@ } [[nodiscard]] WriteData write_to_file(Model* model, std::optional filename_input) { - if (!filename_input.has_value() && model->filename == "") { return WriteData(); } - + if (!filename_input.has_value() && (model->filename == "NO NAME" || model->filename == "")) { + return WriteData(); + } if (filename_input.has_value()) { model->filename = filename_input.value(); } std::ofstream out(model->filename); diff --git a/tests/fixture/test_file_2.txt b/tests/fixture/test_file_2.txt index 5b3b4a7..5bdb67b 100644 --- a/tests/fixture/test_file_2.txt +++ b/tests/fixture/test_file_2.txt @@ -1 +1 @@ -testtest +testtesttest diff --git a/tests/integration/command_mode_test.py b/tests/integration/command_mode_test.py index d72f1c8..be841ca 100644 --- a/tests/integration/command_mode_test.py +++ b/tests/integration/command_mode_test.py @@ -209,8 +209,8 @@ def test_write_all_command(r: TmuxRunner): assert first_line[0] == "h" r.press("u") - time.sleep(0.1) r.iris_cmd("wa") + time.sleep(0.1) with open(r.filename, "r") as f: first_line = f.readlines()[0]