vcl/source/edit/textview.cxx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
New commits: commit cfc3997498d71089ad8fd403a6969d803f926fb8 Author: Andreas Heinisch <andreas.heini...@yahoo.de> AuthorDate: Wed Sep 25 10:04:29 2024 +0200 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Tue Oct 22 21:32:01 2024 +0200 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.kagan...@collabora.com> Reviewed-by: Andreas Heinisch <andreas.heini...@yahoo.de> Tested-by: Jenkins (cherry picked from commit 489613b93846d77a8ee33f5069f079c59dee563b) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174327 Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/vcl/source/edit/textview.cxx b/vcl/source/edit/textview.cxx index 53ed200ce870..ffe10dfa05a2 100644 --- a/vcl/source/edit/textview.cxx +++ b/vcl/source/edit/textview.cxx @@ -1215,7 +1215,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) )