Changeset View
Changeset View
Standalone View
Standalone View
shell/textdocument.cpp
Show First 20 Lines • Show All 497 Lines • ▼ Show 20 Line(s) | |||||
498 | { | 498 | { | ||
499 | if (!d->document) { | 499 | if (!d->document) { | ||
500 | return QString(); | 500 | return QString(); | ||
501 | } | 501 | } | ||
502 | 502 | | |||
503 | KTextEditor::View *view = activeTextView(); | 503 | KTextEditor::View *view = activeTextView(); | ||
504 | 504 | | |||
505 | if (view) { | 505 | if (view) { | ||
506 | KTextEditor::Cursor start = view->cursorPosition(); | 506 | return view->document()->wordAt(view->cursorPosition()); | ||
507 | qCDebug(SHELL) << "got start position from view:" << start.line() << start.column(); | | |||
508 | QString linestr = textLine(); | | |||
509 | int startPos = qMax( qMin( start.column(), linestr.length() - 1 ), 0 ); | | |||
510 | int endPos = startPos; | | |||
511 | startPos --; | | |||
512 | while( startPos >= 0 && ( linestr[startPos].isLetterOrNumber() || linestr[startPos] == '_' || linestr[startPos] == '~' ) ) | | |||
513 | { | | |||
514 | --startPos; | | |||
515 | } | | |||
516 | | ||||
517 | while( endPos < linestr.length() && ( linestr[endPos].isLetterOrNumber() || linestr[endPos] == '_' || linestr[endPos] == '~' ) ) | | |||
brauch: Hmm, the tilde will not be covered by wordAt, will it? This should probably be fixed in the C++… | |||||
Yes, you are correct. But then, why was the '~' in there in the first place? Can anyone tell? And there is another difference below: for empty strings, PartDocument::textWord() was returned. I cannot tell whether this change in behavior will do any bad, since my knowledge of KDevelop mainly lies in KTextEditor :^) dhaumann: Yes, you are correct.
But then, why was the '~' in there in the first place? Can anyone tell? | |||||
518 | { | | |||
519 | ++endPos; | | |||
520 | } | | |||
521 | if( startPos != endPos ) | | |||
522 | { | | |||
523 | qCDebug(SHELL) << "found word" << startPos << endPos << linestr.mid( startPos+1, endPos - startPos - 1 ); | | |||
524 | return linestr.mid( startPos + 1, endPos - startPos - 1 ); | | |||
525 | } | | |||
526 | } | 507 | } | ||
527 | 508 | | |||
528 | return PartDocument::textWord(); | 509 | return PartDocument::textWord(); | ||
529 | } | 510 | } | ||
530 | 511 | | |||
531 | void TextDocument::setTextSelection(const KTextEditor::Range &range) | 512 | void TextDocument::setTextSelection(const KTextEditor::Range &range) | ||
532 | { | 513 | { | ||
533 | if (!range.isValid() || !d->document) | 514 | if (!range.isValid() || !d->document) | ||
▲ Show 20 Lines • Show All 246 Lines • Show Last 20 Lines |
Hmm, the tilde will not be covered by wordAt, will it? This should probably be fixed in the C++ highlighter though, it's wrong here anyways.