Browse Source

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.
Andreas Kling 5 years ago
parent
commit
d127492f0e
1 changed files with 1 additions and 1 deletions
  1. 1 1
      Applications/TextEditor/TextEditorWidget.cpp

+ 1 - 1
Applications/TextEditor/TextEditorWidget.cpp

@@ -499,7 +499,7 @@ void TextEditorWidget::update_title()
 void TextEditorWidget::open_sesame(const String& path)
 void TextEditorWidget::open_sesame(const String& path)
 {
 {
     auto file = Core::File::construct(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());
         GUI::MessageBox::show(String::format("Opening \"%s\" failed: %s", path.characters(), strerror(errno)), "Error", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, window());
         return;
         return;
     }
     }