+ case LFUN_FLEX_INSERT: {
+ // Open the inset, and move the current selection
+ // inside it.
+ bool const sel = cur.selection();
+ doInsertInset(cur, this, cmd, true, true);
+ // Insert auto-insert arguments
+ bool autoargs = false;
+ Layout::LaTeXArgMap args = cur.inset().getLayout().latexargs();
+ Layout::LaTeXArgMap::const_iterator lait = args.begin();
+ Layout::LaTeXArgMap::const_iterator const laend = args.end();
+ for (; lait != laend; ++lait) {
+ Layout::latexarg arg = (*lait).second;
+ if (arg.autoinsert) {
+ // The cursor might have been invalidated by the replaceSelection.
+ cur.buffer()->changed(true);
+ FuncRequest cmd(LFUN_ARGUMENT_INSERT, (*lait).first);
+ lyx::dispatch(cmd);
+ autoargs = true;
+ }
+ }
+ if (!autoargs) {
+ if (sel)
+ cur.leaveInset(cur.inset());
+ cur.posForward();
+ }
+ // Some insets are numbered, others are shown in the outline pane so
+ // let's update the labels and the toc backend.
+ cur.forceBufferUpdate();
+ break;
+ }
+