summaryrefslogtreecommitdiff
path: root/src/plugins/clangcodemodel/clangdiagnosticmanager.cpp
diff options
context:
space:
mode:
authorIvan Donchevskii <ivan.donchevskii@qt.io>2017-05-19 08:55:08 +0200
committerIvan Donchevskii <ivan.donchevskii@qt.io>2017-05-22 13:28:36 +0000
commit707170ca044b5b2c555798682bf5f3bf5334ecdd (patch)
treeb6c2709617b0593c62eaa98afdc9d3d45cd7d693 /src/plugins/clangcodemodel/clangdiagnosticmanager.cpp
parent34702f8441cf890e08cbea91760615c188eac34d (diff)
downloadqt-creator-707170ca044b5b2c555798682bf5f3bf5334ecdd.tar.gz
Clang: make workaround for multibyte utf8
Correct columns in clang diagnostics and completion Task-number: QTCREATORBUG-16775 Change-Id: I7260a0e52007fe261e83492dca5d457c34476497 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
Diffstat (limited to 'src/plugins/clangcodemodel/clangdiagnosticmanager.cpp')
-rw-r--r--src/plugins/clangcodemodel/clangdiagnosticmanager.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/plugins/clangcodemodel/clangdiagnosticmanager.cpp b/src/plugins/clangcodemodel/clangdiagnosticmanager.cpp
index e10793055d..f8afaf6565 100644
--- a/src/plugins/clangcodemodel/clangdiagnosticmanager.cpp
+++ b/src/plugins/clangcodemodel/clangdiagnosticmanager.cpp
@@ -26,6 +26,7 @@
#include "clangdiagnosticfilter.h"
#include "clangdiagnosticmanager.h"
#include "clangisdiagnosticrelatedtolocation.h"
+#include "clangutils.h"
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/actionmanager/command.h>
@@ -60,9 +61,11 @@ QTextEdit::ExtraSelection createExtraSelections(const QTextCharFormat &mainforma
int positionInText(QTextDocument *textDocument,
const ClangBackEnd::SourceLocationContainer &sourceLocationContainer)
{
- auto textBlock = textDocument->findBlockByNumber(int(sourceLocationContainer.line()) - 1);
-
- return textBlock.position() + int(sourceLocationContainer.column()) - 1;
+ auto textBlock = textDocument->findBlockByNumber(
+ static_cast<int>(sourceLocationContainer.line()) - 1);
+ int column = static_cast<int>(sourceLocationContainer.column()) - 1;
+ column -= ClangCodeModel::Utils::extraUtf8CharsShift(textBlock.text(), column);
+ return textBlock.position() + column;
}
void addRangeSelections(const ClangBackEnd::DiagnosticContainer &diagnostic,