vcl/source/edit/textview.cxx |   16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

New commits:
commit 1aa0a43d60336eb1f0e51805939a7cc00b377a2b
Author:     Andreas Heinisch <andreas.heini...@yahoo.de>
AuthorDate: Sun Dec 12 19:54:49 2021 +0100
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Mon Dec 13 07:53:59 2021 +0100

    tdf#145764 - Change behaviour of BASIC IDE Home Key
    
    Pressing the Home Key moves the cursor to the first non-space character
    in the line, whereas pressing it at the first non-space character moves
    it to the beginning of that line
    
    Follow up of: I8eabb6d01b1a4de0d24bf064f82c83342ca91396
    
    Change-Id: I9f4f0b2b602fa0158488959c2e2029f5da315771
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126702
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/vcl/source/edit/textview.cxx b/vcl/source/edit/textview.cxx
index b295b78af8b0..29dad16d1282 100644
--- a/vcl/source/edit/textview.cxx
+++ b/vcl/source/edit/textview.cxx
@@ -1017,10 +1017,16 @@ TextSelection const & TextView::ImpMoveCursor( const 
KeyEvent& rKeyEvent )
         case KEY_DOWN:      aPaM = CursorDown( aPaM );
                             break;
         case KEY_HOME:
-            // tdf#145764 - move cursor to the beginning or first character in 
the same line
-            aPaM = bCtrl                  ? CursorStartOfDoc()
-                   : aPaM.GetIndex() == 0 ? CursorFirstWord( aPaM )
-                                          : CursorStartOfLine( aPaM );
+            if (bCtrl)
+            {
+                aPaM = CursorStartOfDoc();
+            }
+            else
+            {
+                // tdf#145764 - move cursor to the beginning or the first 
non-space character in the same line
+                const TextPaM aFirstWordPaM = CursorFirstWord(aPaM);
+                aPaM = aPaM.GetIndex() == aFirstWordPaM.GetIndex() ? 
CursorStartOfLine(aPaM) : aFirstWordPaM;
+            }
                             break;
         case KEY_END:       aPaM = bCtrl ? CursorEndOfDoc() : CursorEndOfLine( 
aPaM );
                             break;
@@ -1166,7 +1172,7 @@ TextPaM TextView::CursorFirstWord( const TextPaM& rPaM )
     TextNode* pNode = 
mpImpl->mpTextEngine->mpDoc->GetNodes()[aPaM.GetPara()].get();
 
     css::uno::Reference<css::i18n::XBreakIterator> xBI = 
mpImpl->mpTextEngine->GetBreakIterator();
-    aPaM.GetIndex() = xBI->nextWord(pNode->GetText(), 0, 
mpImpl->mpTextEngine->GetLocale(), 
css::i18n::WordType::ANYWORD_IGNOREWHITESPACES).startPos;
+    aPaM.GetIndex() = xBI->beginOfSentence(pNode->GetText(), 0, 
mpImpl->mpTextEngine->GetLocale());
 
     return aPaM;
 }

Reply via email to