>>>>> "Andre" == Andre Poenitz <[EMAIL PROTECTED]> writes:

Andre> What's the actual cursor positioning problem?

Andre> I'd really like to get that fixed by direct calls.

The problem is that, when one types "\frac<space>", the fraction is
inserted, but the cursor is not in the first cell. So I looked at what
LFUN_INSERT_MATH does (in math_nestinset) and found the following
code:

        case LFUN_INSERT_MATH: {
                recordUndo(cur, Undo::ATOMIC);
                MathArray ar;
                asArray(cmd.argument, ar);
                int cell(0);
                if (cmd.argument == "\\root")
                        cell = 1;
                // math macros are nest insets and may have 0 cells.
                // handleNest would crash in this case.
                if (ar.size() == 1 && (ar[0].nucleus()->asNestInset()) &&
                    ar[0].nucleus()->nargs() > MathInset::idx_type(cell)) {
                        cur.handleNest(ar[0], cell);
                } else
                        cur.niceInsert(cmd.argument);
                break;
                }

So the alternative was 

1/ copy this seemingly (to me) fragile code to macroModeClose
-or-
2/ invoke dispatch directly (but add a warning telling this should be fixed)
-or-
3/ create yet another LCursor::fooInsert method, inorder to make
really sure that people will never be able to figure out which one
should be used :)


Andre> Have you checked this leaves the callers intact?

Andre> I.e. typed  \frac<Ctrl-Left> and such?

Erm. It crashes :(

So, what do you propose? I guess I could keep mathMacroClose as it
was, and put the cursor inside the new inset only when space was
pressed?

JMarc

Reply via email to