Commit d1e3f6fa authored by Dominik Haumann's avatar Dominik Haumann

Use Document::currentWord() and some cleanups

REVIEW: 127578
parent f0c285b4
......@@ -692,7 +692,9 @@ void KatePluginGDBView::slotValue()
{
QString variable;
KTextEditor::View* editView = m_mainWin->activeView();
if (editView && editView->selection()) variable = editView->selectionText();
if (editView && editView->selection() && editView->selectionRange().onSingleLine()) {
variable = editView->selectionText();
}
if (variable.isEmpty()) variable = currentWord();
......
......@@ -354,7 +354,7 @@ QString KateCTagsView::currentWord( )
return QString();
}
if (kv->selection()) {
if (kv->selection() && kv->selectionRange().onSingleLine()) {
return kv->selectionText();
}
......
......@@ -416,36 +416,6 @@ void KatePluginSearchView::setCurrentFolder()
}
}
QString KatePluginSearchView::currentWord(const KTextEditor::Document& document, const KTextEditor::Cursor& cursor ) const
{
QString textLine = document.line(cursor.line());
int len = textLine.length();
if (cursor.column() > len) { // Probably because of non-wrapping cursor mode.
return QString();
}
int start = cursor.column();
for(int currPos = cursor.column()-1; currPos >= 0; currPos--) {
if (textLine.at(currPos).isLetterOrNumber() || (textLine[currPos]==QLatin1Char('_')) || (textLine[currPos]==QLatin1Char('~'))) {
start = currPos;
}
else {
break;
}
}
int end = cursor.column();
while (end < len && (textLine.at(end).isLetterOrNumber()
|| (textLine[end]==QLatin1Char('_')) || (textLine[end]==QLatin1Char('~')))) {
end++;
}
return textLine.mid(start, (end - start));
}
void KatePluginSearchView::openSearchView()
{
if (!m_mainWindow) {
......@@ -472,7 +442,7 @@ void KatePluginSearchView::openSearchView()
}
}
if (selection.isEmpty()) {
selection = currentWord(*editView->document(), editView->cursorPosition());
selection = editView->document()->wordAt(editView->cursorPosition());
}
if (!selection.isEmpty() && !selection.contains(QLatin1Char('\n'))) {
......
......@@ -173,7 +173,6 @@ protected:
private:
QTreeWidgetItem *rootFileItem(const QString &url, const QString &fName);
QStringList filterFiles(const QStringList& files) const;
QString currentWord(const KTextEditor::Document& document, const KTextEditor::Cursor& cursor) const;
Ui::SearchDialog m_ui;
QWidget *m_toolView;
......
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