ladybird/DevTools/HackStudio/ProjectFile.cpp
Andreas Kling 390b219cd1 HackStudio: Use GTextDoument::find_all() to implement find-in-files
This fixes the bug seen in my monthly OS update video, where we'd look
through a stale copy of each file, instead of the potentially edited
version in the GTextDocument.

Search results are now also represented as a full GTextRange, and when
you jump to a search result, we select the whole matching range. :^)
2019-11-01 21:31:06 +01:00

16 lines
416 B
C++

#include "ProjectFile.h"
#include <LibCore/CFile.h>
#include <string.h>
const GTextDocument& ProjectFile::document() const
{
if (!m_document) {
m_document = GTextDocument::create(nullptr);
auto file = CFile::construct(m_name);
if (!file->open(CFile::ReadOnly)) {
ASSERT_NOT_REACHED();
}
m_document->set_text(file->read_all());
}
return *m_document;
}