forked from qt-creator/qt-creator
Git: Fix filling commit selection combobox for log
Broken by commit cbb70513bf, which changed the
format for the normal log to override the highlighter.
We still need the hightlighter for the log with diff.
Therefore, a separation between highlighting
and parsing the log is needed to populate the
combobox for commit selection again.
Change-Id: I902ce548fc25875f2cd67b165283ff1236329afa
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
committed by
André Hartmann
parent
9c71e41ad1
commit
d1b0966996
@@ -1048,7 +1048,7 @@ static QStringList normalLogArguments()
|
|||||||
|
|
||||||
const QString logArgs = QStringLiteral(
|
const QString logArgs = QStringLiteral(
|
||||||
"--pretty=format:"
|
"--pretty=format:"
|
||||||
"Commit: %C(%1)%H%Creset %C(%2)%d%Creset%n"
|
"commit %C(%1)%H%Creset %C(%2)%d%Creset%n"
|
||||||
"Author: %C(%3)%an <%ae>%Creset%n"
|
"Author: %C(%3)%an <%ae>%Creset%n"
|
||||||
"Date: %C(%4)%cD%Creset%n%n"
|
"Date: %C(%4)%cD%Creset%n%n"
|
||||||
"%C(%5)%s%Creset%n%n%b%n"
|
"%C(%5)%s%Creset%n%n%b%n"
|
||||||
@@ -1092,8 +1092,12 @@ void GitClient::log(const QString &workingDirectory, const QString &fileName,
|
|||||||
arguments << "-n" << QString::number(logCount);
|
arguments << "-n" << QString::number(logCount);
|
||||||
|
|
||||||
arguments << argWidget->arguments();
|
arguments << argWidget->arguments();
|
||||||
if (arguments.contains(patchOption))
|
if (arguments.contains(patchOption)) {
|
||||||
arguments.removeAll(colorOption);
|
arguments.removeAll(colorOption);
|
||||||
|
editor->setHighlightingEnabled(true);
|
||||||
|
} else {
|
||||||
|
editor->setHighlightingEnabled(false);
|
||||||
|
}
|
||||||
if (!arguments.contains(graphOption) && !arguments.contains(patchOption))
|
if (!arguments.contains(graphOption) && !arguments.contains(patchOption))
|
||||||
arguments << normalLogArguments();
|
arguments << normalLogArguments();
|
||||||
|
|
||||||
|
|||||||
@@ -115,6 +115,7 @@ public:
|
|||||||
QTextCharFormat m_addedTrailingWhiteSpaceFormat;
|
QTextCharFormat m_addedTrailingWhiteSpaceFormat;
|
||||||
|
|
||||||
Internal::FoldingState m_foldingState;
|
Internal::FoldingState m_foldingState;
|
||||||
|
bool m_enabled = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
TextEditor::TextStyle DiffAndLogHighlighterPrivate::analyzeLine(const QString &text) const
|
TextEditor::TextStyle DiffAndLogHighlighterPrivate::analyzeLine(const QString &text) const
|
||||||
@@ -179,16 +180,18 @@ void DiffAndLogHighlighter::highlightBlock(const QString &text)
|
|||||||
const int length = text.length();
|
const int length = text.length();
|
||||||
const TextEditor::TextStyle format = d->analyzeLine(text);
|
const TextEditor::TextStyle format = d->analyzeLine(text);
|
||||||
|
|
||||||
if (format == TextEditor::C_ADDED_LINE) {
|
if (d->m_enabled) {
|
||||||
|
if (format == TextEditor::C_ADDED_LINE) {
|
||||||
// Mark trailing whitespace.
|
// Mark trailing whitespace.
|
||||||
const int trimmedLen = trimmedLength(text);
|
const int trimmedLen = trimmedLength(text);
|
||||||
setFormatWithSpaces(text, 0, trimmedLen, formatForCategory(format));
|
setFormatWithSpaces(text, 0, trimmedLen, formatForCategory(format));
|
||||||
if (trimmedLen != length)
|
if (trimmedLen != length)
|
||||||
setFormat(trimmedLen, length - trimmedLen, d->m_addedTrailingWhiteSpaceFormat);
|
setFormat(trimmedLen, length - trimmedLen, d->m_addedTrailingWhiteSpaceFormat);
|
||||||
} else if (format != TextEditor::C_TEXT) {
|
} else if (format != TextEditor::C_TEXT) {
|
||||||
setFormatWithSpaces(text, 0, length, formatForCategory(format));
|
setFormatWithSpaces(text, 0, length, formatForCategory(format));
|
||||||
} else {
|
} else {
|
||||||
formatSpaces(text);
|
formatSpaces(text);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// codefolding:
|
// codefolding:
|
||||||
@@ -241,4 +244,9 @@ void DiffAndLogHighlighter::setFontSettings(const TextEditor::FontSettings &font
|
|||||||
d->updateOtherFormats();
|
d->updateOtherFormats();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DiffAndLogHighlighter::setEnabled(bool e)
|
||||||
|
{
|
||||||
|
d->m_enabled = e;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace VcsBase
|
} // namespace VcsBase
|
||||||
|
|||||||
@@ -53,6 +53,8 @@ public:
|
|||||||
|
|
||||||
void setFontSettings(const TextEditor::FontSettings &fontSettings) override;
|
void setFontSettings(const TextEditor::FontSettings &fontSettings) override;
|
||||||
|
|
||||||
|
void setEnabled(bool e);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class DiffAndLogHighlighterPrivate;
|
friend class DiffAndLogHighlighterPrivate;
|
||||||
DiffAndLogHighlighterPrivate *const d;
|
DiffAndLogHighlighterPrivate *const d;
|
||||||
|
|||||||
@@ -828,6 +828,12 @@ void VcsBaseEditorWidget::setFileLogAnnotateEnabled(bool e)
|
|||||||
d->m_fileLogAnnotateEnabled = e;
|
d->m_fileLogAnnotateEnabled = e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VcsBaseEditorWidget::setHighlightingEnabled(bool e)
|
||||||
|
{
|
||||||
|
auto dh = static_cast<DiffAndLogHighlighter *>(textDocument()->syntaxHighlighter());
|
||||||
|
dh->setEnabled(e);
|
||||||
|
}
|
||||||
|
|
||||||
QString VcsBaseEditorWidget::workingDirectory() const
|
QString VcsBaseEditorWidget::workingDirectory() const
|
||||||
{
|
{
|
||||||
return d->m_workingDirectory;
|
return d->m_workingDirectory;
|
||||||
|
|||||||
@@ -192,6 +192,8 @@ public:
|
|||||||
bool isFileLogAnnotateEnabled() const;
|
bool isFileLogAnnotateEnabled() const;
|
||||||
void setFileLogAnnotateEnabled(bool e);
|
void setFileLogAnnotateEnabled(bool e);
|
||||||
|
|
||||||
|
void setHighlightingEnabled(bool e);
|
||||||
|
|
||||||
QTextCodec *codec() const;
|
QTextCodec *codec() const;
|
||||||
void setCodec(QTextCodec *);
|
void setCodec(QTextCodec *);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user