Commit b59f9fd0 authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh
Browse files

Git: Support blame for selected lines



Task-number: QTCREATORBUG-16055
Change-Id: Ib24b6d41d5eb12aa0c4ec55377c02c8ae6ea914f
Reviewed-by: Tobias Hunger's avatarTobias Hunger <tobias.hunger@qt.io>
Reviewed-by: default avatarAndré Hartmann <aha_1980@gmx.de>
parent 8fd12818
......@@ -63,6 +63,7 @@
#include <utils/qtcassert.h>
#include <utils/parameteraction.h>
#include <utils/pathchooser.h>
#include <texteditor/texteditor.h>
#include <vcsbase/basevcseditorfactory.h>
#include <vcsbase/submitfilemodel.h>
......@@ -89,6 +90,7 @@
Q_DECLARE_METATYPE(Git::Internal::FileStates)
using namespace Core;
using namespace TextEditor;
using namespace Utils;
using namespace VcsBase;
......@@ -667,7 +669,23 @@ void GitPlugin::blameFile()
const VcsBasePluginState state = currentState();
QTC_ASSERT(state.hasFile(), return);
const int lineNumber = VcsBaseEditor::lineNumberOfCurrentEditor(state.currentFile());
m_gitClient->annotate(state.currentFileTopLevel(), state.relativeCurrentFile(), QString(), lineNumber);
QStringList extraOptions;
if (BaseTextEditor *textEditor = BaseTextEditor::currentTextEditor()) {
QTextCursor cursor = textEditor->textCursor();
if (cursor.hasSelection()) {
QString argument = "-L ";
int selectionStart = cursor.selectionStart();
int selectionEnd = cursor.selectionEnd();
cursor.setPosition(selectionStart);
argument += QString::number(cursor.blockNumber() + 1) + ',';
cursor.setPosition(selectionEnd);
cursor.blockNumber();
argument += QString::number(cursor.blockNumber() + 1);
extraOptions << argument;
}
}
m_gitClient->annotate(state.currentFileTopLevel(), state.relativeCurrentFile(), QString(),
lineNumber, extraOptions);
}
void GitPlugin::logProject()
......
Markdown is supported
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