From d127492f0e3fac6061b32b0c4ce621cd7eb2fe0b Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 4 Jun 2020 22:15:10 +0200 Subject: [PATCH] TextEditor: Allow "TextEditor foo.txt" to create a new file Attempting to open a non-existent file from the command line should not fail, it should just open a new text document with that name. Note that the file is not created until you actually save it. --- Applications/TextEditor/TextEditorWidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Applications/TextEditor/TextEditorWidget.cpp b/Applications/TextEditor/TextEditorWidget.cpp index 2f550507c2..af76c3566c 100644 --- a/Applications/TextEditor/TextEditorWidget.cpp +++ b/Applications/TextEditor/TextEditorWidget.cpp @@ -499,7 +499,7 @@ void TextEditorWidget::update_title() void TextEditorWidget::open_sesame(const String& path) { auto file = Core::File::construct(path); - if (!file->open(Core::IODevice::ReadOnly)) { + if (!file->open(Core::IODevice::ReadOnly) && file->error() != ENOENT) { GUI::MessageBox::show(String::format("Opening \"%s\" failed: %s", path.characters(), strerror(errno)), "Error", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, window()); return; }