forked from qt-creator/qt-creator
Clang: simplify column convertion calls
Pass QTextBlock directly into clangColumn call. Change-Id: I3410a82ed9a84da66e7b430e2aefce64ec459db8 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
@@ -43,6 +43,7 @@
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <QStringList>
|
||||
#include <QTextBlock>
|
||||
|
||||
using namespace ClangCodeModel;
|
||||
using namespace ClangCodeModel::Internal;
|
||||
@@ -190,14 +191,14 @@ void setLastSentDocumentRevision(const QString &filePath, uint revision)
|
||||
document->sendTracker().setLastSentRevision(int(revision));
|
||||
}
|
||||
|
||||
int clangColumn(const QString &lineText, int cppEditorColumn)
|
||||
int clangColumn(const QTextBlock &line, int cppEditorColumn)
|
||||
{
|
||||
// (1) cppEditorColumn is the actual column shown by CppEditor.
|
||||
// (2) The return value is the column in Clang which is the utf8 byte offset from the beginning
|
||||
// of the line.
|
||||
// Here we convert column from (1) to (2).
|
||||
// '+ 1' is for 1-based columns
|
||||
return lineText.left(cppEditorColumn).toUtf8().size() + 1;
|
||||
return line.text().left(cppEditorColumn).toUtf8().size() + 1;
|
||||
}
|
||||
|
||||
} // namespace Utils
|
||||
|
||||
Reference in New Issue
Block a user