forked from qt-creator/qt-creator
Fixed handling of text wrapping and a text layout corner case
Due to using QTextCursor::columnNumber() instead of QTextCursor::positionInBlock(), a lot of code would not work correctly when used with wrapped lines. In addition, there was an issue with columnNumber() returning 0 right after inserting a character before the last character of a line. Reviewed-by: mae
This commit is contained in:
@@ -102,7 +102,7 @@ public:
|
||||
_cursor = cursor;
|
||||
|
||||
QTextBlock block = _cursor.block();
|
||||
const QString blockText = block.text().left(cursor.columnNumber());
|
||||
const QString blockText = block.text().left(cursor.positionInBlock());
|
||||
|
||||
scanner.setScanComments(false);
|
||||
const QList<Token> tokens = scanner(blockText, startState(block));
|
||||
|
||||
@@ -513,7 +513,7 @@ bool CodeCompletion::triggersCompletion(TextEditor::ITextEditable *editor)
|
||||
|
||||
QTextCursor tc = ed->textCursor();
|
||||
QTextBlock block = tc.block();
|
||||
const int column = tc.columnNumber();
|
||||
const int column = tc.positionInBlock();
|
||||
const int blockState = qMax(0, block.previous().userState()) & 0xff;
|
||||
const QString blockText = block.text();
|
||||
|
||||
|
||||
@@ -1130,7 +1130,7 @@ bool QmlJSTextEditor::contextAllowsAutoParentheses(const QTextCursor &cursor, co
|
||||
|
||||
Scanner tokenize;
|
||||
const QList<Token> tokens = tokenize(blockText, blockState);
|
||||
const int pos = cursor.columnNumber();
|
||||
const int pos = cursor.positionInBlock();
|
||||
|
||||
int tokenIndex = 0;
|
||||
for (; tokenIndex < tokens.size(); ++tokenIndex) {
|
||||
|
||||
Reference in New Issue
Block a user