commit cdd21022174fb58dd89dfca4a5192f2381c11e0b
Author: Juergen Spitzmueller <[email protected]>
Date:   Thu Apr 17 07:13:39 2025 +0200

    fix reference-next and findInset with same_content=true (#12979)
    
    This always went to the next inset, no matter its content, as
    the content of the next inset has been compared with itself.
---
 lib/ui/stdcontext.inc |  6 +++---
 src/BufferView.cpp    | 12 +++++++++++-
 src/LyXAction.cpp     |  2 +-
 3 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/lib/ui/stdcontext.inc b/lib/ui/stdcontext.inc
index 5037fa8172..1cd8358faf 100644
--- a/lib/ui/stdcontext.inc
+++ b/lib/ui/stdcontext.inc
@@ -89,7 +89,7 @@ Menuset
 # InsetMathRef context menu
 #
        Menu "context-mathref"
-               Item "Next Cross-Reference|N" "reference-next"
+               Item "Next Cross-Reference or Label with the Same Target|N" 
"reference-next"
                Item "Go to Label|G" "label-goto"
                Separator
                Item "<Reference>|R" "inset-modify changetype ref"
@@ -109,7 +109,7 @@ Menuset
 # InsetRef context menu
 #
        Menu "context-ref"
-               Item "Next Cross-Reference|N" "reference-next"
+               Item "Next Cross-Reference or Label with the Same Target|N" 
"reference-next"
                Item "Go to Label|G" "label-goto"
                Separator
                Item "<Reference>|R" "inset-modify changetype ref"
@@ -133,7 +133,7 @@ Menuset
 # InsetLabel context menu
 #
        Menu "context-label"
-               Item "Next Cross-Reference|N" "reference-next"
+               Item "Next Cross-Reference that Points to This Label|N" 
"reference-next"
                Item "Go Back|G" "bookmark-goto 0"
                Separator
                Item "Copy as Reference|C" "label-copy-as-reference"
diff --git a/src/BufferView.cpp b/src/BufferView.cpp
index a3fed6d802..afe25b4f3c 100644
--- a/src/BufferView.cpp
+++ b/src/BufferView.cpp
@@ -146,12 +146,22 @@ bool findInset(DocIterator & dit, vector<InsetCode> const 
& codes,
 {
        docstring contents;
        DocIterator tmpdit = dit;
+       if (same_content && tmpdit.nextInset()) {
+               // if we are in front of an inset, its content matters
+               InsetCommand const * ic = tmpdit.nextInset()->asInsetCommand();
+               if (ic) {
+                       bool const valid_code = std::find(codes.begin(), 
codes.end(),
+                               ic->lyxCode()) != codes.end();
+                       if (valid_code)
+                               contents = ic->getFirstNonOptParam();
+               }
+       }
        tmpdit.forwardInset();
        if (!tmpdit)
                return false;
 
        Inset const * inset = tmpdit.nextInset();
-       if (same_content && inset) {
+       if (same_content && contents.empty() && inset) {
                InsetCommand const * ic = inset->asInsetCommand();
                if (ic) {
                        bool const valid_code = std::find(codes.begin(), 
codes.end(),
diff --git a/src/LyXAction.cpp b/src/LyXAction.cpp
index 7f669adfaf..b41db2aaed 100644
--- a/src/LyXAction.cpp
+++ b/src/LyXAction.cpp
@@ -3555,8 +3555,8 @@ void LyXAction::init()
 
 /*!
  * \var lyx::FuncCode lyx::LFUN_REFERENCE_NEXT
- * \li Action: Go to the next label or cross-reference.
  * \li Syntax: reference-next
+ * \li Action: Go to the next label or cross-reference of the same target.
  * \li Origin: Dekel, 14 Jan 2001
  * \endvar
  */
-- 
lyx-cvs mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to