Commit 94b672a3 authored by con's avatar con
Browse files

Fix case of tool replacing selection but no selection existing.

Task-number: QTCREATORBUG-3853
parent d7cccb23
......@@ -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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment