Git: Restart instant blame on document save

When the current line is modified, refresh the
blame after saving. Before, the cursor had to
be moved to another line to restart the blame.

Change-Id: I61012f1c8583545b9bc34a71ff63ade2f9cc5b13
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
Andre Hartmann
2023-07-17 07:26:37 +02:00
committed by André Hartmann
parent 5d5a36ef18
commit af5a8fe80c

View File

@@ -437,6 +437,7 @@ public:
QTimer *m_cursorPositionChangedTimer = nullptr; QTimer *m_cursorPositionChangedTimer = nullptr;
std::unique_ptr<BlameMark> m_blameMark; std::unique_ptr<BlameMark> m_blameMark;
QMetaObject::Connection m_blameCursorPosConn; QMetaObject::Connection m_blameCursorPosConn;
QMetaObject::Connection m_documentChangedConn;
GitGrep gitGrep{&m_gitClient}; GitGrep gitGrep{&m_gitClient};
@@ -1462,6 +1463,11 @@ void GitPluginPrivate::setupInstantBlame()
} }
m_cursorPositionChangedTimer->start(500); m_cursorPositionChangedTimer->start(500);
}); });
IDocument *document = editor->document();
m_documentChangedConn = connect(document, &IDocument::changed, this, [this, document] {
if (!document->isModified())
forceInstantBlame();
});
forceInstantBlame(); forceInstantBlame();
}; };
@@ -1590,6 +1596,7 @@ void GitPluginPrivate::stopInstantBlame()
m_blameMark.reset(); m_blameMark.reset();
m_cursorPositionChangedTimer->stop(); m_cursorPositionChangedTimer->stop();
disconnect(m_blameCursorPosConn); disconnect(m_blameCursorPosConn);
disconnect(m_documentChangedConn);
} }
bool GitPluginPrivate::refreshWorkingDirectory(const FilePath &workingDirectory) bool GitPluginPrivate::refreshWorkingDirectory(const FilePath &workingDirectory)