diff options
author | Andreas Heinisch <andreas.heinisch@yahoo.de> | 2024-09-25 10:04:29 +0200 |
---|---|---|
committer | Andreas Heinisch <andreas.heinisch@yahoo.de> | 2024-10-01 22:38:59 +0200 |
commit | 489613b93846d77a8ee33f5069f079c59dee563b (patch) | |
tree | 1b59729f21a12391f5614f60e1221f66c8dd429e /vcl/source/edit | |
parent | 52942df3125d8ea3725f2847695cf7281bb4580b (diff) |
tdf#160202 - Don't extend selection over two words
Don't extend the selection over two separate string in the BASIC editor.
Probably, the BreakIteratorImpl::nextWord needs to be corrected which could lead to unwanted side effects.
Change-Id: I0e980006cca672fb63216dc860c12a7004bfd759
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173900
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Reviewed-by: Andreas Heinisch <andreas.heinisch@yahoo.de>
Tested-by: Jenkins
Diffstat (limited to 'vcl/source/edit')
-rw-r--r-- | vcl/source/edit/textview.cxx | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/vcl/source/edit/textview.cxx b/vcl/source/edit/textview.cxx index d87213a413c3..da64ffe4db47 100644 --- a/vcl/source/edit/textview.cxx +++ b/vcl/source/edit/textview.cxx @@ -1213,7 +1213,19 @@ TextPaM TextView::CursorWordRight( const TextPaM& rPaM ) if ( aPaM.GetIndex() < pNode->GetText().getLength() ) { css::uno::Reference < css::i18n::XBreakIterator > xBI = mpImpl->mpTextEngine->GetBreakIterator(); - aPaM.GetIndex() = xBI->nextWord( pNode->GetText(), aPaM.GetIndex(), mpImpl->mpTextEngine->GetLocale(), css::i18n::WordType::ANYWORD_IGNOREWHITESPACES ).endPos; + // tdf#160202 - NextWord unexpectedly skips two words at the start of any word + const auto aWordBoundary = xBI->getWordBoundary( + pNode->GetText(), aPaM.GetIndex(), mpImpl->mpTextEngine->GetLocale(), + css::i18n::WordType::ANYWORD_IGNOREWHITESPACES, true); + + // Check if the current index is inside the word boundary + if (aWordBoundary.startPos <= aPaM.GetIndex() && aPaM.GetIndex() < aWordBoundary.endPos) + aPaM.GetIndex() = aWordBoundary.startPos; + else + aPaM.GetIndex() = xBI->nextWord(pNode->GetText(), aPaM.GetIndex(), + mpImpl->mpTextEngine->GetLocale(), + css::i18n::WordType::ANYWORD_IGNOREWHITESPACES) + .endPos; mpImpl->mpTextEngine->GetWord( aPaM, nullptr, &aPaM ); } else if ( aPaM.GetPara() < ( mpImpl->mpTextEngine->mpDoc->GetNodes().size()-1) ) |