summaryrefslogtreecommitdiff
path: root/Applications/TextEditor
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-06-04 22:15:10 +0200
committerAndreas Kling <kling@serenityos.org>2020-06-04 22:15:10 +0200
commitd127492f0e3fac6061b32b0c4ce621cd7eb2fe0b (patch)
tree3e8164b881cfe1a05eb29102b87960e4fd7b3d8b /Applications/TextEditor
parentb59f4632d5b77d2ef4502fb6bbd4d2c4a2fa03f5 (diff)
downloadserenity-d127492f0e3fac6061b32b0c4ce621cd7eb2fe0b.zip
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.
Diffstat (limited to 'Applications/TextEditor')
-rw-r--r--Applications/TextEditor/TextEditorWidget.cpp2
1 files changed, 1 insertions, 1 deletions
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;
}