Fixed renaming when the cursor is at the end of the ID.

Task-number: QTCREATORBUG-909.
Reviewed-by: Thorbjørn
This commit is contained in:
Erik Verbruggen
2010-03-25 14:47:14 +01:00
parent dab558d4fe
commit ca6f735204

View File

@@ -907,9 +907,13 @@ void QmlJSTextEditor::setFontSettings(const TextEditor::FontSettings &fs)
QString QmlJSTextEditor::wordUnderCursor() const
{
QTextCursor tc = textCursor();
const QChar ch = characterAt(tc.position() - 1);
// make sure that we're not at the start of the next word.
if (ch.isLetterOrNumber() || ch == QLatin1Char('_'))
tc.movePosition(QTextCursor::Left);
tc.movePosition(QTextCursor::StartOfWord);
tc.movePosition(QTextCursor::EndOfWord, QTextCursor::KeepAnchor);
const QString word= tc.selectedText();
const QString word = tc.selectedText();
return word;
}