commit d66d655bfaceb7894b864108aa8b31458ec11139
Author: Jean-Marc Lasgouttes <[email protected]>
Date:   Fri Aug 28 17:24:58 2026 +0200

    Fix cursor position when going to previous cell in a macro template
    
    Additionally, move the getStatus handling of
    LFUN_CELL_BACKWARD/FORWARD where it belongs.
    
    Fixes bug #13237.
    
    (cherry picked from commit b3cdb64198038842df116498c50b781531208768)
---
 src/mathed/InsetMathGrid.cpp |  5 -----
 src/mathed/InsetMathNest.cpp | 12 +++++++++++-
 status.25x                   |  3 +++
 3 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/src/mathed/InsetMathGrid.cpp b/src/mathed/InsetMathGrid.cpp
index 9d29246d2f..df173ef388 100644
--- a/src/mathed/InsetMathGrid.cpp
+++ b/src/mathed/InsetMathGrid.cpp
@@ -1797,11 +1797,6 @@ bool InsetMathGrid::getStatus(Cursor & cur, FuncRequest 
const & cmd,
                status.setEnabled(cur.idx() != cur.lastidx());
                return true;
 
-       case LFUN_CELL_BACKWARD:
-       case LFUN_CELL_FORWARD:
-               status.setEnabled(true);
-               return true;
-
        default:
                break;
        }
diff --git a/src/mathed/InsetMathNest.cpp b/src/mathed/InsetMathNest.cpp
index 2790b58719..4310edc1c9 100644
--- a/src/mathed/InsetMathNest.cpp
+++ b/src/mathed/InsetMathNest.cpp
@@ -225,7 +225,12 @@ bool InsetMathNest::idxPrev(Cursor & cur) const
 
 bool InsetMathNest::idxBackward(Cursor & cur) const
 {
-       return idxPrev(cur);
+       LASSERT(&cur.inset() == this, return false);
+       if (cur.idx() == 0)
+               return false;
+       --cur.idx();
+       cur.pos() = cur.lastpos();
+       return true;
 }
 
 
@@ -1865,6 +1870,11 @@ bool InsetMathNest::getStatus(Cursor & cur, FuncRequest 
const & cmd,
                return true;
        }
 
+       case LFUN_CELL_BACKWARD:
+       case LFUN_CELL_FORWARD:
+               flag.setEnabled(true);
+               return true;
+
        default:
                ret = false;
                break;
diff --git a/status.25x b/status.25x
index 612b5e9664..c36fd7d0cf 100644
--- a/status.25x
+++ b/status.25x
@@ -67,6 +67,9 @@ What's new
 
 - Do not open inset settings when click happened elsewhere (bug 13340).
 
+- Fix cursor position when going to previous cell in a macro template
+  (bug 13237).
+
 
 * INTERNALS
 
-- 
lyx-cvs mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to