diff options
author | Ivan Donchevskii <ivan.donchevskii@qt.io> | 2017-11-29 16:08:06 +0100 |
---|---|---|
committer | Ivan Donchevskii <ivan.donchevskii@qt.io> | 2018-01-26 15:39:31 +0000 |
commit | 09310bcdc68e4242106e3f15761116797f8f0d78 (patch) | |
tree | 478b750fe83632d4c66f131792322a11df4a6193 /src/plugins/clangcodemodel/clangeditordocumentprocessor.cpp | |
parent | 6deec195f1b00ba941c12eee9ea1024d3ddabc54 (diff) |
Clang: fix utf8 related column numbers
Use new clang_getFileContents to efficiently convert
utf8 byte offsets from line start to column numbers.
Also provide simplier backwards convertion to pass
resulting utf8 offset to clang.
Task-number: QTCREATORBUG-16941
Change-Id: If0e58fe01ad3e281b7e952e972b9e86f6e75aadb
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
Diffstat (limited to 'src/plugins/clangcodemodel/clangeditordocumentprocessor.cpp')
-rw-r--r-- | src/plugins/clangcodemodel/clangeditordocumentprocessor.cpp | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/src/plugins/clangcodemodel/clangeditordocumentprocessor.cpp b/src/plugins/clangcodemodel/clangeditordocumentprocessor.cpp index b0c1959dbb..e1a02f453d 100644 --- a/src/plugins/clangcodemodel/clangeditordocumentprocessor.cpp +++ b/src/plugins/clangcodemodel/clangeditordocumentprocessor.cpp @@ -331,20 +331,19 @@ ClangEditorDocumentProcessor::cursorInfo(const CppTools::CursorInfoParams ¶m { int line, column; convertPosition(params.textCursor, &line, &column); - ++column; // for 1-based columns if (!isCursorOnIdentifier(params.textCursor)) return defaultCursorInfoFuture(); const QTextBlock block = params.textCursor.document()->findBlockByNumber(line - 1); - column += ClangCodeModel::Utils::extraUtf8CharsShift(block.text(), column); + const QString stringOnTheLeft = block.text().left(column); + column = stringOnTheLeft.toUtf8().size() + 1; // '+ 1' is for 1-based columns const CppTools::SemanticInfo::LocalUseMap localUses = CppTools::BuiltinCursorInfo::findLocalUses(params.semanticInfo.doc, line, column); return m_communicator.requestReferences(simpleFileContainer(), static_cast<quint32>(line), static_cast<quint32>(column), - textDocument(), localUses); } @@ -361,8 +360,7 @@ QFuture<CppTools::CursorInfo> ClangEditorDocumentProcessor::requestLocalReferenc return m_communicator.requestLocalReferences(simpleFileContainer(), static_cast<quint32>(line), - static_cast<quint32>(column), - textDocument()); + static_cast<quint32>(column)); } QFuture<CppTools::SymbolInfo> |