TextEditor: Don't allow opening directories
Previously it was possible to open a directory in the TextEditor application. Like device files, these are now rejected with an error message.
This commit is contained in:
parent
d5828dbecb
commit
2e1a01a499
Notes:
sideshowbarker
2024-07-18 12:19:07 +09:00
Author: https://github.com/sinjs 🔰 Commit: https://github.com/SerenityOS/serenity/commit/2e1a01a499d Pull-request: https://github.com/SerenityOS/serenity/pull/8024 Reviewed-by: https://github.com/trflynn89
1 changed files with 5 additions and 0 deletions
|
@ -653,6 +653,11 @@ bool MainWidget::open_file(const String& path)
|
|||
return false;
|
||||
}
|
||||
|
||||
if (file->is_directory()) {
|
||||
GUI::MessageBox::show(window(), String::formatted("Opening \"{}\" failed: Can't open directories", path), "Error", GUI::MessageBox::Type::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
m_editor->set_text(file->read_all());
|
||||
|
||||
set_path(LexicalPath(path));
|
||||
|
|
Loading…
Add table
Reference in a new issue