sc/source/core/data/table1.cxx |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

New commits:
commit ce8c23e885404f971bc41b48cea8f9b56e345f80
Author:     Caolán McNamara <caolan.mcnam...@collabora.com>
AuthorDate: Tue Jul 25 10:08:38 2023 +0100
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Tue Aug 1 16:04:20 2023 +0200

    Resolves: tdf#156462 ctrl+left in calc doesn't always jump to the correct 
cell
    
    since:
    
    commit 9e2d48b9e04f7ea895fb095699c32ed8a44eb129
    Date:   Wed Mar 30 11:58:04 2022 +0200
    
        reduce Calc's INITIALCOLCOUNT to 1
    
    but:
    
    commit a680f6988482f13489d6c802b6078d43564ae934
    Date:   Wed Jun 7 22:48:01 2017 +0530
    
        tdf#50916 : More refactoring in table1.cxx
    
    is likely also relevant wrt: "If nCol is in the unallocated range
    [nLastCol+1, MAXCOL], then move it directly to nLastCol"
    
    If the cursor is outside the allocated column range then the search
    started 1 cell to the left of the last allocated column
    
    Change-Id: I854173ad13d50e50d85e9902b31585e8ae3e2c0e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154910
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index 308025656319..9064c5241acf 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -1344,14 +1344,14 @@ SCCOL ScTable::FindNextVisibleColWithContent( SCCOL 
nCol, bool bRight, SCROW nRo
     }
     else
     {
-        // If nCol is in the unallocated range [nLastCol+1, 
rDocument.MaxCol()], then move it directly to nLastCol
+        if(nCol == 0)
+            return 0;
+
+        // If nCol is in the unallocated range [nLastCol+1, 
rDocument.MaxCol()], then move it directly after nLastCol
         // as there is no data in the unallocated range. This also makes the 
search faster and avoids
         // the need for more range checks in the loop below.
         if ( nCol > nLastCol )
-            nCol = nLastCol;
-
-        if(nCol == 0)
-            return 0;
+            nCol = nLastCol + 1;
 
         do
         {

Reply via email to