From af5a8fe80c05caa7f2c965f032e53fe3c0599772 Mon Sep 17 00:00:00 2001 From: Andre Hartmann Date: Mon, 17 Jul 2023 07:26:37 +0200 Subject: [PATCH] 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 --- src/plugins/git/gitplugin.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/plugins/git/gitplugin.cpp b/src/plugins/git/gitplugin.cpp index c7d2f1f0661..223cecf0b69 100644 --- a/src/plugins/git/gitplugin.cpp +++ b/src/plugins/git/gitplugin.cpp @@ -437,6 +437,7 @@ public: QTimer *m_cursorPositionChangedTimer = nullptr; std::unique_ptr m_blameMark; QMetaObject::Connection m_blameCursorPosConn; + QMetaObject::Connection m_documentChangedConn; GitGrep gitGrep{&m_gitClient}; @@ -1462,6 +1463,11 @@ void GitPluginPrivate::setupInstantBlame() } m_cursorPositionChangedTimer->start(500); }); + IDocument *document = editor->document(); + m_documentChangedConn = connect(document, &IDocument::changed, this, [this, document] { + if (!document->isModified()) + forceInstantBlame(); + }); forceInstantBlame(); }; @@ -1590,6 +1596,7 @@ void GitPluginPrivate::stopInstantBlame() m_blameMark.reset(); m_cursorPositionChangedTimer->stop(); disconnect(m_blameCursorPosConn); + disconnect(m_documentChangedConn); } bool GitPluginPrivate::refreshWorkingDirectory(const FilePath &workingDirectory)