forked from qt-creator/qt-creator
Git: Instant Blame: Use original line number for blame
The line might have been moved and therfore using the original line number asures the full blame is scrolled to the correct position. Change-Id: I07478d499af3509670a7d91771b2ee9777a06b3c Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
committed by
André Hartmann
parent
bfe1258d1b
commit
f005f2c4be
@@ -79,8 +79,8 @@ bool BlameMark::addToolTipContent(QLayout *target) const
|
||||
const QString originalFileName = m_info.originalFileName;
|
||||
if (link.startsWith("blame")) {
|
||||
qCInfo(log).nospace().noquote() << "Blaming: \"" << path << "/" << originalFileName
|
||||
<< "\":" << m_info.line << " @ " << sha1;
|
||||
gitClient().annotate(path, originalFileName, m_info.line, sha1);
|
||||
<< "\":" << m_info.originalLine << " @ " << sha1;
|
||||
gitClient().annotate(path, originalFileName, m_info.originalLine, sha1);
|
||||
} else {
|
||||
qCInfo(log).nospace().noquote() << "Showing file: \"" << path << "/"
|
||||
<< originalFileName << "\" @ " << sha1;
|
||||
@@ -226,7 +226,8 @@ static CommitInfo parseBlameOutput(const QStringList &blame, const Utils::FilePa
|
||||
if (blame.size() <= 12)
|
||||
return result;
|
||||
|
||||
result.sha1 = blame.at(0).left(40);
|
||||
const QStringList firstLineParts = blame.at(0).split(" ");
|
||||
result.sha1 = firstLineParts.first();
|
||||
result.author = blame.at(1).mid(7);
|
||||
result.authorMail = blame.at(2).mid(13).chopped(1);
|
||||
if (result.author == author.name || result.authorMail == author.email)
|
||||
@@ -243,6 +244,10 @@ static CommitInfo parseBlameOutput(const QStringList &blame, const Utils::FilePa
|
||||
else
|
||||
result.originalFileName = blame.at(11).mid(9);
|
||||
result.line = line;
|
||||
if (firstLineParts.size() > 1)
|
||||
result.originalLine = firstLineParts.at(1).toInt();
|
||||
else
|
||||
result.originalLine = line;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@@ -25,9 +25,10 @@ public:
|
||||
QString authorMail;
|
||||
QDateTime authorTime;
|
||||
QString summary;
|
||||
Utils::FilePath filePath;
|
||||
QString originalFileName; // relative file path from project root
|
||||
int line = -1;
|
||||
Utils::FilePath filePath; ///< absolute file path for current file
|
||||
QString originalFileName; ///< relative file path from project root for the original file
|
||||
int line = -1; ///< current line number in current file
|
||||
int originalLine = -1; ///< original line number in the original file
|
||||
};
|
||||
|
||||
class BlameMark : public TextEditor::TextMark
|
||||
|
Reference in New Issue
Block a user