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.
This commit is contained in:
Andreas Kling 2020-06-04 22:15:10 +02:00
parent b59f4632d5
commit d127492f0e
Notes: sideshowbarker 2024-07-19 05:49:46 +09:00

View file

@ -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;
}