Commit f9f3e05e authored by Christoph Cullmann's avatar Christoph Cullmann 🐮
Browse files

SVN_SILENT clang-format

parent e662d644
......@@ -48,9 +48,9 @@ ColorPickerInlineNoteProvider::ColorPickerInlineNoteProvider(KTextEditor::Docume
auto lineChanged = [this](const int line) {
if (m_startChangedLines == -1 || m_endChangedLines == -1) {
m_startChangedLines = line;
// changed line is directly above/below the previous changed line, so we just update them
// changed line is directly above/below the previous changed line, so we just update them
} else if (line == m_endChangedLines) { // handled below. Condition added here to avoid fallthrough
} else if (line == m_startChangedLines-1) {
} else if (line == m_startChangedLines - 1) {
m_startChangedLines = line;
} else if (line < m_startChangedLines || line > m_endChangedLines) {
// changed line is outside the range of previous changes. Change proably skipped lines
......@@ -126,10 +126,11 @@ void ColorPickerInlineNoteProvider::updateColorMatchingCriteria()
colorRegex = QLatin1String("(?!)");
}
m_colorRegex.setPattern(colorRegex);
m_colorRegex.setPattern(colorRegex);
}
void ColorPickerInlineNoteProvider::updateNotes(int startLine, int endLine) {
void ColorPickerInlineNoteProvider::updateNotes(int startLine, int endLine)
{
startLine = startLine < -1 ? -1 : startLine;
if (startLine == -1) {
startLine = 0;
......@@ -161,8 +162,7 @@ QVector<int> ColorPickerInlineNoteProvider::inlineNotes(int line) const
continue;
}
if (lineText.at(match.capturedStart()) == QLatin1Char('#')
&& !m_matchHexLengths.contains(match.capturedLength()-1)) {
if (lineText.at(match.capturedStart()) == QLatin1Char('#') && !m_matchHexLengths.contains(match.capturedLength() - 1)) {
// matching for this hex color format is disabled
continue;
}
......@@ -184,7 +184,7 @@ QVector<int> ColorPickerInlineNoteProvider::inlineNotes(int line) const
QSize ColorPickerInlineNoteProvider::inlineNoteSize(const KTextEditor::InlineNote &note) const
{
return QSize(note.lineHeight()-1, note.lineHeight()-1);
return QSize(note.lineHeight() - 1, note.lineHeight() - 1);
}
void ColorPickerInlineNoteProvider::paintInlineNote(const KTextEditor::InlineNote &note, QPainter &painter) const
......@@ -193,7 +193,8 @@ void ColorPickerInlineNoteProvider::paintInlineNote(const KTextEditor::InlineNot
auto colorEnd = note.position().column();
const QVector<int> &colorNoteIndices = m_colorNoteIndices[line].colorNoteIndices;
// Since the colorNoteIndices are inserted in left-to-right (increasing) order in inlineNotes(), we can use binary search to find the index (or color note number) for the line
// Since the colorNoteIndices are inserted in left-to-right (increasing) order in inlineNotes(), we can use binary search to find the index (or color note
// number) for the line
const int colorNoteNumber = std::lower_bound(colorNoteIndices.cbegin(), colorNoteIndices.cend(), colorEnd) - colorNoteIndices.cbegin();
auto colorStart = m_colorNoteIndices[line].otherColorIndices[colorNoteNumber];
......@@ -223,7 +224,8 @@ void ColorPickerInlineNoteProvider::inlineNoteActivated(const KTextEditor::Inlin
auto colorEnd = note.position().column();
const QVector<int> &colorNoteIndices = m_colorNoteIndices[line].colorNoteIndices;
// Since the colorNoteIndices are inserted in left-to-right (increasing) order in inlineNotes, we can use binary search to find the index (or color note number) for the line
// Since the colorNoteIndices are inserted in left-to-right (increasing) order in inlineNotes, we can use binary search to find the index (or color note
// number) for the line
const int colorNoteNumber = std::lower_bound(colorNoteIndices.cbegin(), colorNoteIndices.cend(), colorEnd) - colorNoteIndices.cbegin();
auto colorStart = m_colorNoteIndices[line].otherColorIndices[colorNoteNumber];
if (colorStart > colorEnd) {
......@@ -238,7 +240,7 @@ void ColorPickerInlineNoteProvider::inlineNoteActivated(const KTextEditor::Inlin
dialogOptions |= QColorDialog::NoButtons;
title = i18n("View Color [Read only]");
}
const QColor newColor = QColorDialog::getColor(oldColor, const_cast<KTextEditor::View*>(note.view()), title, dialogOptions);
const QColor newColor = QColorDialog::getColor(oldColor, const_cast<KTextEditor::View *>(note.view()), title, dialogOptions);
if (!newColor.isValid()) {
return;
}
......@@ -285,7 +287,8 @@ void KateColorPickerPlugin::addDocument(KTextEditor::Document *doc)
});
}
void KateColorPickerPlugin::readConfig() {
void KateColorPickerPlugin::readConfig()
{
for (auto colorNoteProvider : m_inlineColorNoteProviders.values()) {
colorNoteProvider->updateColorMatchingCriteria();
colorNoteProvider->updateNotes();
......
......@@ -29,7 +29,7 @@ public:
void updateColorMatchingCriteria();
// if startLine == -1, update all notes. endLine is optional
void updateNotes(int startLine=-1, int endLine=-1);
void updateNotes(int startLine = -1, int endLine = -1);
QVector<int> inlineNotes(int line) const override;
QSize inlineNoteSize(const KTextEditor::InlineNote &note) const override;
......@@ -43,8 +43,8 @@ private:
int m_previousNumLines = -1;
struct ColorIndices {
// When m_putPreviewAfterColor is true, otherColorIndices holds the starting color indices while colorNoteIndices holds the end color indices (and vice versa)
// colorNoteIndices[i] corresponds to otherColorIndices[i]
// When m_putPreviewAfterColor is true, otherColorIndices holds the starting color indices while colorNoteIndices holds the end color indices (and vice
// versa) colorNoteIndices[i] corresponds to otherColorIndices[i]
QVector<int> colorNoteIndices;
QVector<int> otherColorIndices;
};
......
......@@ -136,7 +136,8 @@ public:
static const uint64_t ModifierMask =
Qt::ShiftModifier | Qt::ControlModifier | Qt::AltModifier | Qt::MetaModifier | Qt::KeypadModifier | Qt::GroupSwitchModifier;
Private() : QTextBrowser(nullptr)
Private()
: QTextBrowser(nullptr)
{
setWindowFlags(Qt::FramelessWindowHint | Qt::BypassGraphicsProxyWidget | Qt::ToolTip);
setWordWrapMode(QTextOption::NoWrap);
......@@ -168,20 +169,17 @@ public:
{
switch (event->type()) {
case QEvent::KeyPress:
case QEvent::ShortcutOverride:
{
case QEvent::ShortcutOverride: {
QKeyEvent *ke = static_cast<QKeyEvent *>(event);
if (ke->matches(QKeySequence::Copy)) {
copy();
}
else if (ke->matches(QKeySequence::SelectAll)) {
} else if (ke->matches(QKeySequence::SelectAll)) {
selectAll();
}
event->accept();
return true;
}
case QEvent::KeyRelease:
{
case QEvent::KeyRelease: {
QKeyEvent *ke = static_cast<QKeyEvent *>(event);
int ignoreKey = 0;
if (m_ignoreKeySequence.count() > 0) {
......@@ -269,9 +267,7 @@ protected:
void leaveEvent(QEvent *event) override
{
if (!m_hideTimer.isActive() && !m_inContextMenu &&
textCursor().selectionStart() == textCursor().selectionEnd()
) {
if (!m_hideTimer.isActive() && !m_inContextMenu && textCursor().selectionStart() == textCursor().selectionEnd()) {
hideTooltip();
}
return QTextBrowser::leaveEvent(event);
......@@ -280,9 +276,7 @@ protected:
void mouseMoveEvent(QMouseEvent *event) override
{
auto pos = event->pos();
if (rect().contains(pos) || m_inContextMenu ||
textCursor().selectionStart() != textCursor().selectionEnd()
) {
if (rect().contains(pos) || m_inContextMenu || textCursor().selectionStart() != textCursor().selectionEnd()) {
return QTextBrowser::mouseMoveEvent(event);
}
hideTooltip();
......@@ -302,9 +296,14 @@ private:
KSyntaxHighlighting::Repository m_syntaxHlRepo;
};
GitBlameTooltip::GitBlameTooltip() : d(new GitBlameTooltip::Private()) {}
GitBlameTooltip::~GitBlameTooltip() { delete d; }
GitBlameTooltip::GitBlameTooltip()
: d(new GitBlameTooltip::Private())
{
}
GitBlameTooltip::~GitBlameTooltip()
{
delete d;
}
void GitBlameTooltip::show(const QString &text, QPointer<KTextEditor::View> view)
{
......
......@@ -19,7 +19,6 @@ class View;
class GitBlameTooltip
{
public:
GitBlameTooltip();
~GitBlameTooltip();
......
......@@ -4,7 +4,6 @@
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#ifndef KateGitBlamePlugin_h
#define KateGitBlamePlugin_h
......@@ -17,13 +16,13 @@
#include <QProcess>
#include <QDateTime>
#include <QHash>
#include <QList>
#include <QLocale>
#include <QRegularExpression>
#include <QVariant>
#include <QVector>
#include <QDateTime>
#include <QLocale>
struct KateGitBlameInfo {
QString commitHash;
......@@ -53,8 +52,6 @@ private:
QLocale m_locale;
};
class KateGitBlamePlugin : public KTextEditor::Plugin
{
Q_OBJECT
......
......@@ -1669,7 +1669,8 @@ public:
h({m_accept_edit, QString()});
}
template<typename Collection> void checkEditResult(const Collection &c)
template<typename Collection>
void checkEditResult(const Collection &c)
{
if (c.empty()) {
showMessage(i18n("No edits"), KTextEditor::Message::Information);
......@@ -2184,7 +2185,7 @@ public:
lineRanges.clear();
// qDebug() << "line:" << line.line << ", toks " << line.tokens.size();
for (const auto &token : line.tokens) {
// qDebug() << "token:" << token.character << token.length << token.scope;
// qDebug() << "token:" << token.character << token.length << token.scope;
auto attribute = scopes.attrForScope(token.scope);
if (!attribute) {
continue;
......
......@@ -23,14 +23,16 @@ namespace utils
{
// template helper
// function bind helpers
template<typename R, typename T, typename Tp, typename... Args> inline std::function<R(Args...)> mem_fun(R (T::*pm)(Args...), Tp object)
template<typename R, typename T, typename Tp, typename... Args>
inline std::function<R(Args...)> mem_fun(R (T::*pm)(Args...), Tp object)
{
return [object, pm](Args... args) {
return (object->*pm)(std::forward<Args>(args)...);
};
}
template<typename R, typename T, typename Tp, typename... Args> inline std::function<R(Args...)> mem_fun(R (T::*pm)(Args...) const, Tp object)
template<typename R, typename T, typename Tp, typename... Args>
inline std::function<R(Args...)> mem_fun(R (T::*pm)(Args...) const, Tp object)
{
return [object, pm](Args... args) {
return (object->*pm)(std::forward<Args>(args)...);
......@@ -38,7 +40,8 @@ template<typename R, typename T, typename Tp, typename... Args> inline std::func
}
// prevent argument deduction
template<typename T> struct identity {
template<typename T>
struct identity {
typedef T type;
};
......@@ -46,7 +49,8 @@ template<typename T> struct identity {
static const int TIMEOUT_SHUTDOWN = 200;
template<typename T> using ReplyHandler = std::function<void(const T &)>;
template<typename T>
using ReplyHandler = std::function<void(const T &)>;
using ErrorReplyHandler = ReplyHandler<LSPResponseError>;
using DocumentSymbolsReplyHandler = ReplyHandler<QList<LSPSymbolInformation>>;
......
......@@ -64,7 +64,6 @@ static QString rootForDocumentAndRootIndicationFileName(KTextEditor::Document *d
#include <memory>
// helper guard to handle revision (un)lock
struct RevisionGuard {
QPointer<KTextEditor::Document> m_doc;
......
......@@ -11,18 +11,18 @@
#include <ktexteditorpreview_debug.h>
// KF
#include <KTextEditor/Document>
#include <KTextEditor/MainWindow>
#include <KTextEditor/View>
#include <KAboutPluginDialog>
#include <KPluginMetaData>
#include <KConfigGroup>
#include <KGuiItem>
#include <KLocalizedString>
#include <KMimeTypeTrader>
#include <KParts/ReadOnlyPart>
#include <KPluginMetaData>
#include <KService>
#include <KSharedConfig>
#include <KTextEditor/Document>
#include <KTextEditor/MainWindow>
#include <KTextEditor/View>
#include <KToggleAction>
#include <KXMLGUIFactory>
......
......@@ -406,7 +406,11 @@ QVector<QString> KateProjectWorker::filesFromGit(const QDir &dir, bool recursive
/**
* ls-files untracked
*/
const QStringList lsFilesUntrackedArgs{QStringLiteral("ls-files"), QStringLiteral("-z"), QStringLiteral("--others"), QStringLiteral("--exclude-standard"), QStringLiteral(".")};
const QStringList lsFilesUntrackedArgs{QStringLiteral("ls-files"),
QStringLiteral("-z"),
QStringLiteral("--others"),
QStringLiteral("--exclude-standard"),
QStringLiteral(".")};
// ls-files + ls-files untracked
return gitFiles(dir, recursive, lsFilesArgs) << gitFiles(dir, recursive, lsFilesUntrackedArgs);
......
......@@ -68,6 +68,7 @@ protected:
sourceModel()->setData(idx, score, FuzzyScore);
return res;
}
private:
static constexpr int FuzzyScore = Qt::UserRole + 1;
QString m_pattern;
......@@ -358,4 +359,3 @@ void StashDialog::showStash(const QByteArray &index)
git->setArguments(args);
git->start(QProcess::ReadOnly);
}
......@@ -98,8 +98,12 @@ QVector<KateSearchMatch> SearchDiskFiles::searchSingleLineRegExp(QFile &file)
const int preContextStart = qMax(0, column - MatchModel::PreContextLen);
const QString preContext = line.mid(preContextStart, column - preContextStart);
const QString postContext = line.mid(endColumn, MatchModel::PostContextLen);
matches.push_back(
KateSearchMatch{preContext, match.captured(), postContext, QString(), KTextEditor::Range{currentLineNumber, column, currentLineNumber, column + match.capturedLength()}, true});
matches.push_back(KateSearchMatch{preContext,
match.captured(),
postContext,
QString(),
KTextEditor::Range{currentLineNumber, column, currentLineNumber, column + match.capturedLength()},
true});
// advance match column
columnToStartMatch = column + match.capturedLength();
......
......@@ -35,7 +35,6 @@ void UrlInfoTest::someCursors()
QCOMPARE(UrlInfo(QStringLiteral("fish://remote/file?some=variable&line=4&")).cursor, KTextEditor::Cursor(3, 0));
QCOMPARE(UrlInfo(QStringLiteral("file:///directory/file?some=variable&column=5&other=value&line=6")).cursor, KTextEditor::Cursor(5, 4));
QCOMPARE(UrlInfo(QStringLiteral("~/file?line=7")).url.hasQuery(), false);
}
void UrlInfoTest::urlWithColonAtStart()
......
......@@ -198,7 +198,7 @@ bool KateApp::startupKate()
KTextEditor::Document *doc = nullptr;
const QString codec_name = codec ? QString::fromLatin1(codec->name()) : QString();
for (const auto& positionalArgument : m_args.positionalArguments()) {
for (const auto &positionalArgument : m_args.positionalArguments()) {
UrlInfo info(positionalArgument);
// this file is no local dir, open it, else warn
......@@ -401,7 +401,8 @@ bool KateApp::setCursor(int line, int column)
return true;
}
bool KateApp::hasCursorInArgs() {
bool KateApp::hasCursorInArgs()
{
return m_args.isSet(QStringLiteral("line")) || m_args.isSet(QStringLiteral("column"));
}
......
......@@ -223,11 +223,11 @@ public:
bool setCursor(int line, int column);
/**
* Checks if --line and/or --column args were provided and attempts
* to set cursor position in the provided or active view accordingly.
*
* @param view Optional view to apply changes on.
*/
* Checks if --line and/or --column args were provided and attempts
* to set cursor position in the provided or active view accordingly.
*
* @param view Optional view to apply changes on.
*/
void setCursorFromArgs(KTextEditor::View *view = nullptr);
/**
......
......@@ -35,7 +35,11 @@
#include <KApplicationTrader>
#include <KConfigGroup>
#include <KEditToolBar>
#include <KFileItem>
#include <KHelpClient>
#include <KIO/ApplicationLauncherJob>
#include <KIO/Job>
#include <KIO/JobUiDelegate>
#include <KLocalizedString>
#include <KMessageBox>
#include <KMultiTabBar>
......@@ -50,10 +54,6 @@
#include <KWindowConfig>
#include <KWindowSystem>
#include <KXMLGUIFactory>
#include <KIO/ApplicationLauncherJob>
#include <KIO/JobUiDelegate>
#include <KFileItem>
#include <KIO/Job>
#include <QApplication>
#include <QDesktopWidget>
......
......@@ -680,7 +680,7 @@ void KateViewSpace::restoreConfig(KateViewManager *viewMan, const KConfigBase *c
// with applying saved session settings until the remote's temp file is initialised.
if (!view->document()->url().isLocalFile()) {
QSharedPointer<QMetaObject::Connection> conn(new QMetaObject::Connection());
auto handler = [conn, view, configGroup](KTextEditor::Document *doc){
auto handler = [conn, view, configGroup](KTextEditor::Document *doc) {
disconnect(*conn);
view->readSessionConfig(configGroup);
};
......@@ -698,7 +698,8 @@ void KateViewSpace::restoreConfig(KateViewManager *viewMan, const KConfigBase *c
auto *doc = KateApp::self()->documentManager()->documentList().first();
if (!fn.isEmpty()) {
QUrl url(fn);
KateApp::self()->documentManager()->documentInfo(doc)->doPostLoadOperations = !url.isLocalFile() && (KateApp::self()->hasCursorInArgs() || url.hasQuery());
KateApp::self()->documentManager()->documentInfo(doc)->doPostLoadOperations =
!url.isLocalFile() && (KateApp::self()->hasCursorInArgs() || url.hasQuery());
}
viewMan->createView(doc, this);
}
......
......@@ -178,8 +178,17 @@ static bool fuzzy_internal::fuzzy_match_recursive(QStringView::const_iterator pa
int recursiveScore = 0;
const auto strNextChar = std::next(str);
if (!matchingInSequence
&& fuzzy_match_recursive(
pattern, strNextChar, recursiveScore, strBegin, strEnd, patternEnd, matches, recursiveMatches, nextMatch, totalMatches, recursionCount)) {
&& fuzzy_match_recursive(pattern,
strNextChar,
recursiveScore,
strBegin,
strEnd,
patternEnd,
matches,
recursiveMatches,
nextMatch,
totalMatches,
recursionCount)) {
// Pick best recursive score
if (!recursiveMatch || recursiveScore > bestRecursiveScore) {
memcpy(bestRecursiveMatches, recursiveMatches, maxMatches);
......
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