Fix case of tool replacing selection but no selection existing.

Task-number: QTCREATORBUG-3853
This commit is contained in:
con
2011-02-28 14:48:42 +01:00
parent d7cccb234c
commit 94b672a31b

View File

@@ -276,11 +276,11 @@ void TextEditorPlugin::updateCurrentSelection(const QString &text)
if (editor) {
int pos = editor->position();
int anchor = editor->position(ITextEditor::Anchor);
if (anchor < 0) // no selection
anchor = pos;
int selectionLength = anchor-pos;
if (selectionLength < 0)
selectionLength = -selectionLength;
if (selectionLength == 0)
return;
int start = qMin(pos, anchor);
editor->setCursorPosition(start);
editor->replace(selectionLength, text);