ClangFormat: Fix the return value for the line offset

Return -1 for the lines which do not exist in the document.

Change-Id: Ieccb2121f7db260bf72b36886d1f820af01cca0d
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
This commit is contained in:
Ivan Donchevskii
2018-12-11 09:40:50 +01:00
parent b382d83fab
commit 4a693e91db

View File

@@ -142,6 +142,9 @@ QTextCursor wordStartCursor(const QTextCursor &textCursor)
int utf8NthLineOffset(const QTextDocument *textDocument, const QByteArray &buffer, int line)
{
if (textDocument->blockCount() < line)
return -1;
if (textDocument->characterCount() == buffer.size() + 1)
return textDocument->findBlockByNumber(line - 1).position();