Commit 4344f092 authored by Waqar Ahmed's avatar Waqar Ahmed
Browse files

Start git blame with a delay on activeView

Otherwise if one is switching views quickly, there is a noticeable
slowness in view-switching.
parent f6bee316
Pipeline #230893 passed with stage
in 5 minutes and 34 seconds
......@@ -186,7 +186,13 @@ KateGitBlamePluginView::KateGitBlamePluginView(KateGitBlamePlugin *plugin, KText
m_inlineNoteProvider.cycleMode();
});
connect(m_mainWindow, &KTextEditor::MainWindow::viewChanged, this, &KateGitBlamePluginView::viewChanged);
m_startBlameTimer.setSingleShot(true);
m_startBlameTimer.setInterval(400);
m_startBlameTimer.callOnTimeout(this, &KateGitBlamePluginView::startGitBlameForActiveView);
connect(m_mainWindow, &KTextEditor::MainWindow::viewChanged, this, [this](KTextEditor::View *) {
m_startBlameTimer.start();
});
connect(&m_blameInfoProc, static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished), this, &KateGitBlamePluginView::blameFinished);
......@@ -220,13 +226,14 @@ QPointer<KTextEditor::Document> KateGitBlamePluginView::activeDocument() const
return nullptr;
}
void KateGitBlamePluginView::viewChanged(KTextEditor::View *view)
void KateGitBlamePluginView::startGitBlameForActiveView()
{
if (m_lastView) {
qobject_cast<KTextEditor::InlineNoteInterface *>(m_lastView)->unregisterInlineNoteProvider(&m_inlineNoteProvider);
}
m_lastView = view;
auto *view = m_mainWindow->activeView();
m_lastView = view;
if (view == nullptr || view->document() == nullptr) {
return;
}
......
......@@ -22,6 +22,7 @@
#include <QLocale>
#include <QPointer>
#include <QRegularExpression>
#include <QTimer>
#include <QVariant>
#include <QVector>
......@@ -94,7 +95,7 @@ public:
private:
void sendMessage(const QString &text, bool error);
void viewChanged(KTextEditor::View *view);
void startGitBlameForActiveView();
void startBlameProcess(const QUrl &url);
void blameFinished(int exitCode, QProcess::ExitStatus exitStatus);
......@@ -125,6 +126,7 @@ private:
class CommitDiffTreeView *m_commitFilesView;
std::unique_ptr<QWidget> m_toolView;
QPointer<KTextEditor::View> m_diffView;
QTimer m_startBlameTimer;
};
#endif // KateGitBlamePlugin_h
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment