mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 12:48:10 +00:00
HackStudio: Indicate git changes in the editor's gutter
"+" for added lines, "!" for changed, "-" for removed.
This commit is contained in:
parent
8501617fcb
commit
d5828dbecb
4 changed files with 71 additions and 0 deletions
|
@ -92,6 +92,7 @@ void EditorWrapper::set_filename(const String& filename)
|
|||
{
|
||||
m_filename = filename;
|
||||
update_title();
|
||||
update_diff();
|
||||
}
|
||||
|
||||
void EditorWrapper::save()
|
||||
|
@ -99,6 +100,32 @@ void EditorWrapper::save()
|
|||
editor().write_to_file(filename());
|
||||
m_document_dirty = false;
|
||||
update_title();
|
||||
update_diff();
|
||||
editor().update();
|
||||
}
|
||||
|
||||
void EditorWrapper::update_diff()
|
||||
{
|
||||
if (m_git_repo)
|
||||
m_hunks = Diff::parse_hunks(m_git_repo->unstaged_diff(LexicalPath(filename())).value());
|
||||
}
|
||||
|
||||
void EditorWrapper::set_project_root(LexicalPath const& project_root)
|
||||
{
|
||||
m_project_root = project_root;
|
||||
|
||||
auto result = GitRepo::try_to_create(m_project_root);
|
||||
switch (result.type) {
|
||||
case GitRepo::CreateResult::Type::Success:
|
||||
m_git_repo = result.repo;
|
||||
break;
|
||||
case GitRepo::CreateResult::Type::GitProgramNotFound:
|
||||
break;
|
||||
case GitRepo::CreateResult::Type::NoGitRepo:
|
||||
break;
|
||||
default:
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
}
|
||||
|
||||
void EditorWrapper::update_title()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue