commit 3900ca4c13ded618b01eacf842d780a9e0d1ed39
Author: Juergen Spitzmueller <[email protected]>
Date:   Sun Aug 24 16:49:05 2025 +0200

    Support full counter syntax in InsetLayout LabelString (rest of #12532)
    
    This fruit was hanging much lower than I thought.
---
 lib/RELEASE-NOTES            |  3 ++-
 lib/doc/Customization.lyx    | 14 ++++++++++++--
 lib/doc/de/Customization.lyx | 11 +++++++++++
 src/insets/InsetFlex.cpp     |  6 ++++--
 src/insets/InsetFoot.cpp     |  5 +++--
 5 files changed, 32 insertions(+), 7 deletions(-)

diff --git a/lib/RELEASE-NOTES b/lib/RELEASE-NOTES
index 8438127b38..6a8dca1087 100644
--- a/lib/RELEASE-NOTES
+++ b/lib/RELEASE-NOTES
@@ -69,7 +69,8 @@
 - If InsetLayout used a counter, the value of this counter has been 
automatically
   appended to the LabelString for the button of the inset. Now, the counter
   needs to be added to the LabelString explicitly via the placeholder '##'
-  (e.g., "Foot ##").
+  (e.g., "Foot ##") or special commands such as \the<counter> or 
\arabic{counter},
+  like in LabelStrings of other elements.
 
 !!!The following LyX documents have been moved in 2.5:
 
diff --git a/lib/doc/Customization.lyx b/lib/doc/Customization.lyx
index 26343659e1..d857b37e9c 100644
--- a/lib/doc/Customization.lyx
+++ b/lib/doc/Customization.lyx
@@ -14310,7 +14310,7 @@ LabelCounter
 \end_inset
 
  is set,
- this string can be contain the special formatting commands described in 
+ this string might contain the special formatting commands described in 
 \begin_inset CommandInset ref
 LatexCommand ref
 reference "subsec:Counters"
@@ -21896,7 +21896,7 @@ Branch
 
 ) modify this label on the fly.
 
-\change_inserted -712698321 1756021044
+\change_inserted -712698321 1756046664
  If the inset has a counter,
  it can be added to the label via the placeholder 
 \begin_inset Flex Code
@@ -21922,6 +21922,16 @@ Foot ##
 \end_inset
 
 ).
+ Furthermore,
+ the label string might contain the special formatting commands described in 
+\begin_inset CommandInset ref
+LatexCommand ref
+reference "subsec:Counters"
+nolink "false"
+
+\end_inset
+
+ if it should refer to other counter values.
 \change_unchanged
 
 \end_layout
diff --git a/lib/doc/de/Customization.lyx b/lib/doc/de/Customization.lyx
index 9729929330..87a1643657 100644
--- a/lib/doc/de/Customization.lyx
+++ b/lib/doc/de/Customization.lyx
@@ -19900,6 +19900,17 @@ Fußnote ##
 \end_inset
 
 ).
+ Außerdem kann die Zeichenkette spezielle Formatierungsbefehle enthalten,
+ wie sie in 
+\begin_inset CommandInset ref
+LatexCommand ref
+reference "subsec:Zähler"
+nolink "false"
+
+\end_inset
+
+ beschrieben sind,
+ falls die Marke andere Zählerwerte beinhalten soll.
 \end_layout
 
 \begin_layout Description
diff --git a/src/insets/InsetFlex.cpp b/src/insets/InsetFlex.cpp
index fd9d4677c9..8ef483582f 100644
--- a/src/insets/InsetFlex.cpp
+++ b/src/insets/InsetFlex.cpp
@@ -146,9 +146,11 @@ void InsetFlex::updateBuffer(ParIterator const & it, 
UpdateType utype, bool cons
 {
        BufferParams const & bp = buffer().masterBuffer()->params();
        InsetLayout const & il = getLayout();
-       docstring custom_label = translateIfPossible(il.labelstring());
 
        Counters & cnts = bp.documentClass().counters();
+       string const lc = it.paragraph().getParLanguage(bp)->code();
+       docstring custom_label =
+               cnts.counterLabel(translateIfPossible(il.labelstring()), lc);
        docstring const & count = il.counter();
        bool const have_counter = cnts.hasCounter(count);
        if (have_counter) {
@@ -164,7 +166,7 @@ void InsetFlex::updateBuffer(ParIterator const & it, 
UpdateType utype, bool cons
                        cnts.step(count, utype);
                        if (il.stepParentCounter())
                                cnts.stepParent(count, utype);
-                       val = cnts.theCounter(count, 
it.paragraph().getParLanguage(bp)->code());
+                       val = cnts.theCounter(count, lc);
                }
                custom_label = support::subst(custom_label, from_ascii("##"), 
val);
        }
diff --git a/src/insets/InsetFoot.cpp b/src/insets/InsetFoot.cpp
index 4bac2a4a2b..c5cf131488 100644
--- a/src/insets/InsetFoot.cpp
+++ b/src/insets/InsetFoot.cpp
@@ -76,16 +76,17 @@ void InsetFoot::updateBuffer(ParIterator const & it, 
UpdateType utype, bool cons
                }
        }
 
-       Language const * lang = it.paragraph().getParLanguage(bp);
+       string const lc = it.paragraph().getParLanguage(bp)->code();
        InsetLayout const & il = getLayout();
        docstring const & count = il.counter();
        custom_label_ = translateIfPossible(il.labelstring());
+       custom_label_ = 
cnts.counterLabel(translateIfPossible(il.labelstring()), lc);
 
        docstring val = from_ascii("#");
        if (cnts.hasCounter(count)) {
                int v = cnts.value(count);
                cnts.step(count, utype);
-               val = cnts.theCounter(count, lang->code());
+               val = cnts.theCounter(count, lc);
                if (deleted)
                        // un-step after deleted counter
                        cnts.set(count, v);
-- 
lyx-cvs mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to