forked from qt-creator/qt-creator
Editor: remove TextDocumentManipulator
Change-Id: Iacd7cd40ace77c79eecca3e4e699eb308d0c27de Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -355,11 +355,12 @@ bool QmlJSAssistProposalItem::prematurelyApplies(const QChar &c) const
|
||||
|| (text().endsWith(QLatin1Char('.')) && c == QLatin1Char('.'));
|
||||
}
|
||||
|
||||
void QmlJSAssistProposalItem::applyContextualContent(TextEditor::TextDocumentManipulator &manipulator,
|
||||
void QmlJSAssistProposalItem::applyContextualContent(TextEditorWidget *editorWidget,
|
||||
int basePosition) const
|
||||
{
|
||||
const int currentPosition = manipulator.currentPosition();
|
||||
manipulator.replace(basePosition, currentPosition - basePosition, QString());
|
||||
QTC_ASSERT(editorWidget, return);
|
||||
const int currentPosition = editorWidget->position();
|
||||
editorWidget->replace(basePosition, currentPosition - basePosition, QString());
|
||||
|
||||
QString content = text();
|
||||
int cursorOffset = 0;
|
||||
@@ -378,17 +379,17 @@ void QmlJSAssistProposalItem::applyContextualContent(TextEditor::TextDocumentMan
|
||||
int replacedLength = 0;
|
||||
for (int i = 0; i < replaceable.length(); ++i) {
|
||||
const QChar a = replaceable.at(i);
|
||||
const QChar b = manipulator.characterAt(manipulator.currentPosition() + i);
|
||||
const QChar b = editorWidget->characterAt(editorWidget->position() + i);
|
||||
if (a == b)
|
||||
++replacedLength;
|
||||
else
|
||||
break;
|
||||
}
|
||||
const int length = manipulator.currentPosition() - basePosition + replacedLength;
|
||||
manipulator.replace(basePosition, length, content);
|
||||
const int length = editorWidget->position() - basePosition + replacedLength;
|
||||
editorWidget->replace(basePosition, length, content);
|
||||
if (cursorOffset) {
|
||||
manipulator.setCursorPosition(manipulator.currentPosition() + cursorOffset);
|
||||
manipulator.addAutoCompleteSkipPosition();
|
||||
editorWidget->setCursorPosition(editorWidget->position() + cursorOffset);
|
||||
editorWidget->setAutoCompleteSkipPosition(editorWidget->textCursor());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ class QmlJSAssistProposalItem final : public TextEditor::AssistProposalItem
|
||||
{
|
||||
public:
|
||||
bool prematurelyApplies(const QChar &c) const final;
|
||||
void applyContextualContent(TextEditor::TextDocumentManipulator &manipulator,
|
||||
void applyContextualContent(TextEditor::TextEditorWidget *editorWidget,
|
||||
int basePosition) const final;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user