From ca6f73520403e4c7f8daf167bcef7072e0549083 Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Thu, 25 Mar 2010 14:47:14 +0100 Subject: [PATCH] Fixed renaming when the cursor is at the end of the ID. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTCREATORBUG-909. Reviewed-by: Thorbjørn --- src/plugins/qmljseditor/qmljseditor.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/plugins/qmljseditor/qmljseditor.cpp b/src/plugins/qmljseditor/qmljseditor.cpp index ce557ffbdf0..6a9512a0b5c 100644 --- a/src/plugins/qmljseditor/qmljseditor.cpp +++ b/src/plugins/qmljseditor/qmljseditor.cpp @@ -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; }