diff --git a/src/completion/katewordcompletion.cpp b/src/completion/katewordcompletion.cpp --- a/src/completion/katewordcompletion.cpp +++ b/src/completion/katewordcompletion.cpp @@ -27,6 +27,7 @@ #include "kateglobal.h" #include "katepartdebug.h" #include "katedefaultcolors.h" +#include "katehighlight.h" #include #include @@ -212,6 +213,7 @@ QSet result; const int minWordSize = qMax(2, qobject_cast(view)->config()->wordCompletionMinimalWordLength()); const int lines = view->document()->lines(); + KateHighlighting *h = qobject_cast(view)->doc()->highlight(); for (int line = 0; line < lines; line++) { const QString &text = view->document()->line(line); int wordBegin = 0; @@ -221,7 +223,7 @@ while (offset < end) { const QChar c = text.at(offset); // increment offset when at line end, so we take the last character too - if ((! c.isLetterOrNumber() && c != QLatin1Char('_')) || (offset == end - 1 && offset++)) { + if (!h->isInWord(c) || (offset == end - 1 && offset++)) { if (offset - wordBegin > minWordSize && (line != range.end().line() || offset != range.end().column())) { /** * don't add the word we are inside with cursor! @@ -247,14 +249,13 @@ ) const { KTextEditor::ViewPrivate *v = qobject_cast (view); + KateHighlighting *h = v->doc()->highlight(); if (v->config()->wordCompletionRemoveTail()) { int tailStart = word.end().column(); const QString &line = view->document()->line(word.end().line()); int tailEnd = line.length(); for (int i = word.end().column(); i < tailEnd; ++i) { - // Letters, numbers and underscore are part of a word! - /// \todo Introduce configurable \e word-separators?? - if (!line[i].isLetterOrNumber() && line[i] != QLatin1Char('_')) { + if (!h->isInWord(line[i])) { tailEnd = i; } } @@ -294,9 +295,10 @@ int col = position.column(); KTextEditor::Document *doc = view->document(); + KateHighlighting *h = qobject_cast(view)->doc()->highlight(); while (col > 0) { const QChar c = (doc->characterAt(KTextEditor::Cursor(line, col - 1))); - if (c.isLetterOrNumber() || c.isMark() || c == QLatin1Char('_')) { + if (h->isInWord(c)) { col--; continue; }