Skip to content

Commit 3d25372

Browse files
committed
ticket:5333 Use the whole suggested word instead of completing it
1 parent 0adf2ff commit 3d25372

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

OMEdit/OMEdit/OMEditGUI/Editors/BaseEditor.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1583,8 +1583,13 @@ void PlainTextEdit::insertCompletionItem(const QModelIndex &index)
15831583
QStringList completionlength = completerItem.mValue.split("\n");
15841584
QTextCursor cursor = textCursor();
15851585
cursor.beginEditBlock();
1586-
int extra = completionlength[0].length() - mpCompleter->completionPrefix().length();
1587-
cursor.insertText(completionlength[0].right(extra));
1586+
/* Ticket #5333#comment:7. Since we allow case insensitive matching so we have to replace the whole word with
1587+
* completion text instead of just completing it.
1588+
*/
1589+
cursor.setPosition(cursor.position(), QTextCursor::MoveAnchor);
1590+
cursor.setPosition(cursor.position() - mpCompleter->completionPrefix().length(), QTextCursor::KeepAnchor);
1591+
cursor.removeSelectedText();
1592+
cursor.insertText(completionlength[0]);
15881593
// store the cursor position to be used for selecting text when inserting code snippets
15891594
int currentpos = cursor.position();
15901595
int startpos = currentpos-completionlength[0].length();

0 commit comments

Comments
 (0)