diff --git a/language/interfaces/editorcontext.cpp b/language/interfaces/editorcontext.cpp --- a/language/interfaces/editorcontext.cpp +++ b/language/interfaces/editorcontext.cpp @@ -35,12 +35,7 @@ m_url = view->document()->url(); m_position = position; m_currentLine = view->document()->line(m_position.line()); - int wordStart = m_position.column(); - int wordEnd = m_position.column(); - while(wordStart > 0 && wordStart < m_currentLine.length() && (m_currentLine[wordStart-1].isLetterOrNumber() || m_currentLine[wordStart-1] == '_')) - --wordStart; - while(wordEnd >= 0 && wordEnd < m_currentLine.length() && (m_currentLine[wordEnd].isLetterOrNumber() || m_currentLine[wordEnd] == '_')) - ++wordEnd; + m_currentWord = view->document()->wordAt(m_position); } QUrl m_url; diff --git a/shell/textdocument.cpp b/shell/textdocument.cpp --- a/shell/textdocument.cpp +++ b/shell/textdocument.cpp @@ -503,26 +503,7 @@ KTextEditor::View *view = activeTextView(); if (view) { - KTextEditor::Cursor start = view->cursorPosition(); - qCDebug(SHELL) << "got start position from view:" << start.line() << start.column(); - QString linestr = textLine(); - int startPos = qMax( qMin( start.column(), linestr.length() - 1 ), 0 ); - int endPos = startPos; - startPos --; - while( startPos >= 0 && ( linestr[startPos].isLetterOrNumber() || linestr[startPos] == '_' || linestr[startPos] == '~' ) ) - { - --startPos; - } - - while( endPos < linestr.length() && ( linestr[endPos].isLetterOrNumber() || linestr[endPos] == '_' || linestr[endPos] == '~' ) ) - { - ++endPos; - } - if( startPos != endPos ) - { - qCDebug(SHELL) << "found word" << startPos << endPos << linestr.mid( startPos+1, endPos - startPos - 1 ); - return linestr.mid( startPos + 1, endPos - startPos - 1 ); - } + return view->document()->wordAt(view->cursorPosition()); } return PartDocument::textWord();