1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 15:17:36 +00:00

HackStudio: Migrate git-diff indicators to TextEditor API

As part of this, the CodeDocument now keeps track of the kind of
difference for each line. Previously, we iterated every hunk every time
the editor was painted, but now we do that once whenever the diff
changes, and then save the type of difference for each line.
This commit is contained in:
Sam Atkins 2023-03-15 11:33:18 +00:00 committed by Andreas Kling
parent 620bf45f43
commit 0761926127
5 changed files with 84 additions and 31 deletions

View file

@ -13,6 +13,8 @@
namespace HackStudio {
class Editor;
class CodeDocument final : public GUI::TextDocument {
public:
virtual ~CodeDocument() override = default;
@ -29,6 +31,15 @@ public:
virtual bool is_code_document() const override final { return true; }
enum class DiffType {
None,
AddedLine,
ModifiedLine,
DeletedLinesBefore,
};
DiffType line_difference(size_t line) const;
void set_line_differences(Badge<Editor>, Vector<DiffType>);
private:
explicit CodeDocument(DeprecatedString const& file_path, Client* client = nullptr);
explicit CodeDocument(Client* client = nullptr);
@ -37,6 +48,8 @@ private:
Optional<Syntax::Language> m_language;
Vector<size_t> m_breakpoint_lines;
Optional<size_t> m_execution_position;
Vector<DiffType> m_line_differences;
};
}