mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-01 00:38:48 +00:00
HackStudio: Don't assert when project has non-existent file
If a project contains "foo.cpp" but we can't open "foo.cpp", just go with an empty text document for now, and we'll create "foo.cpp" when the user saves.
This commit is contained in:
parent
387607503c
commit
47a3d81731
Notes:
sideshowbarker
2024-07-19 01:44:30 +09:00
Author: https://github.com/awesomekling
Commit: 47a3d81731
1 changed files with 7 additions and 4 deletions
|
@ -39,11 +39,14 @@ const GUI::TextDocument& ProjectFile::document() const
|
|||
{
|
||||
if (!m_document) {
|
||||
m_document = CodeDocument::create(LexicalPath(m_name));
|
||||
auto file = Core::File::construct(m_name);
|
||||
if (!file->open(Core::File::ReadOnly)) {
|
||||
ASSERT_NOT_REACHED();
|
||||
auto file_or_error = Core::File::open(m_name, Core::File::ReadOnly);
|
||||
if (file_or_error.is_error()) {
|
||||
warnln("Couldn't open '{}': {}", m_name, file_or_error.error());
|
||||
// This is okay though, we'll just go with an empty document and create the file when saving.
|
||||
} else {
|
||||
auto& file = *file_or_error.value();
|
||||
m_document->set_text(file.read_all());
|
||||
}
|
||||
m_document->set_text(file->read_all());
|
||||
}
|
||||
return *m_document;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue