commit f8722a1a7125695acb2174bac3452ccfb9fd7bf0
Author: Juergen Spitzmueller <[email protected]>
Date:   Sat Oct 10 09:55:09 2026 +0200

    Honor AutoInsert for flex insets without selection
---
 src/Text.cpp | 78 +++++++++++++++++++++++++++++++++++-------------------------
 1 file changed, 45 insertions(+), 33 deletions(-)

diff --git a/src/Text.cpp b/src/Text.cpp
index 577c48922d..8f0b01f872 100644
--- a/src/Text.cpp
+++ b/src/Text.cpp
@@ -3546,6 +3546,44 @@ void ipaChar(Cursor & cur, InsetIPAChar::Kind kind)
 }
 
 
+bool doAutoInsert(Cursor & cur)
+{
+       bool autoargs = false, inautoarg = false;
+       Layout::LaTeXArgMap args = cur.inset().getLayout().args();
+       for (auto const & argt : args) {
+               Layout::latexarg arg = argt.second;
+               if (!inautoarg && arg.insertonnewline && cur.pos() > 0) {
+                       FuncRequest cmd2(LFUN_PARAGRAPH_BREAK);
+                       lyx::dispatch(cmd2);
+               }
+               if (arg.autoinsert) {
+                       // The cursor might have been invalidated by the 
replaceSelection.
+                       cur.buffer()->changed(true);
+                       // If we had already inserted an arg automatically,
+                       // leave this now in order to insert the next one.
+                       if (inautoarg) {
+                               cur.leaveInset(cur.inset());
+                               cur.setCurrentFont();
+                               cur.posForward();
+                               if (arg.insertonnewline && cur.pos() > 0) {
+                                       FuncRequest cmd2(LFUN_PARAGRAPH_BREAK);
+                                       lyx::dispatch(cmd2);
+                               }
+                       }
+                       if (prefixIs(argt.first, "post:"))
+                               cur.pos() = cur.paragraph().size();
+                       else
+                               cur.pos() = 0;
+                       FuncRequest cmd2(LFUN_ARGUMENT_INSERT, argt.first);
+                       lyx::dispatch(cmd2);
+                       inautoarg = true;
+                       autoargs = true;
+               }
+       }
+       return autoargs;
+}
+
+
 bool doInsertInset(Cursor & cur, Text * text,
                          FuncRequest const & cmd, bool edit,
                          bool pastesel, bool resetfont = false)
@@ -3652,8 +3690,13 @@ bool doInsertInset(Cursor & cur, Text * text,
        if (edit)
                inset->edit(cur, true);
 
-       if (!gotsel || !pastesel)
+       if (!gotsel || !pastesel) {
+               if (inset_text) {
+                       // Insert auto-insert arguments
+                       doAutoInsert(cur);
+               }
                return true;
+       }
 
        pasteFromTemp(cur, cur.buffer()->errorList("Paste"));
        cur.buffer()->errors("Paste");
@@ -3676,38 +3719,7 @@ bool doInsertInset(Cursor & cur, Text * text,
                if (!move_layout)
                        
cur.paragraph().setPlainOrDefaultLayout(bparams.documentClass());
                // Insert auto-insert arguments
-               bool autoargs = false, inautoarg = false;
-               Layout::LaTeXArgMap args = cur.inset().getLayout().args();
-               for (auto const & argt : args) {
-                       Layout::latexarg arg = argt.second;
-                       if (!inautoarg && arg.insertonnewline && cur.pos() > 0) 
{
-                               FuncRequest cmd2(LFUN_PARAGRAPH_BREAK);
-                               lyx::dispatch(cmd2);
-                       }
-                       if (arg.autoinsert) {
-                               // The cursor might have been invalidated by 
the replaceSelection.
-                               cur.buffer()->changed(true);
-                               // If we had already inserted an arg 
automatically,
-                               // leave this now in order to insert the next 
one.
-                               if (inautoarg) {
-                                       cur.leaveInset(cur.inset());
-                                       cur.setCurrentFont();
-                                       cur.posForward();
-                                       if (arg.insertonnewline && cur.pos() > 
0) {
-                                               FuncRequest 
cmd2(LFUN_PARAGRAPH_BREAK);
-                                               lyx::dispatch(cmd2);
-                                       }
-                               }
-                               if (prefixIs(argt.first, "post:"))
-                                       cur.pos() = cur.paragraph().size();
-                               else
-                                       cur.pos() = 0;
-                               FuncRequest cmd2(LFUN_ARGUMENT_INSERT, 
argt.first);
-                               lyx::dispatch(cmd2);
-                               autoargs = true;
-                               inautoarg = true;
-                       }
-               }
+               bool autoargs = doAutoInsert(cur);
                Cursor old = cur;
                if (!autoargs)
                        cur.leaveInset(*inset);
-- 
lyx-cvs mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to