On Sun, Feb 26, 2006 at 07:25:51PM +0100, Georg Baum wrote:
> Am Sonntag, 26. Februar 2006 17:53 schrieb Martin Vermeer:
> > Yes... but now insertion of a decoration "around" selected math text
> > fails. The problem which this patch originally tried to fix.
> 
> Of course. The patch was only meant to show where the problem is, it was 
> by no means a finished fix.
> 
> > The assumption here appears to be that the argument to give to the
> > LFUN_PASTE call is the _text_ to be pasted into the doc. Checking the
> > places where LFUN_PASTE is executed (i.e., text2.C and
> > math_nestinset.C), however, shows that the text to be pasted comes from
> > _buffer number_ n, an integer contained in the cmd.argument transferred.
> > 
> > So I believe there is a "thinko" here, which explains why the
> > selection disappears into the black hole and is never inserted -- at
> > least for math.
> 
> That is indeed a problem, but unrelated, because LCursor::paste() is not 
> invoked for \mathbb. I filed it at 
> http://bugzilla.lyx.org/show_bug.cgi?id=2327 and attached also a possible 
> fix.
> 
> There seems to be a different thinko involved in the \mathbb problem: 
> LCursor::handleNest() operates on a selection, but the selection may be 
> empty if you insert '\mathbb R' from the math panel (and its contents 
> will be wrong even if it is not empty).
> The attached patch improves the situation a bit by invoking handleNest() 
> only if there is a selection. That makes '\mathbb R' work again for the 
> case where nothing is selected.
> If you try to insert '\mathbb R' over a selection, you'll convert the 
> selection to \mathbb font. That is also the case in 1.3, but in 1.3 
> you'll get additionally the roginila mathbb argument, which is missing 
> with the patch, so some more work needs to be done.

Attached the best I can come up with for now. Working are:

1) fonts from the panel around selection
2) decorations from the panel over/under selection
3) compound symbols from the panel, type \mathbb R, without sel
4) same with sel: result [sel|R] in mathbb font. I say we can live with
that.

I propose this as the patch for 1.4.1 (not 1.4.0 I think; it's cosmetic
and there's a workaround).

- Martin

PS There's one other call to cur.paste(data) in nestinset, which tries to
do something that won't work anyway in this way, and that I propose to
dump together with the whole sorry cur.paste method. Later....

PS2 Is my impression right and is 1.4.0 ready for release once the 2316
fix is in? With luck, we'll have a February release...

Index: cursor.C
===================================================================
--- cursor.C    (revision 13276)
+++ cursor.C    (working copy)
@@ -379,6 +390,8 @@
 }
 
 
+// Don't use this routine. It is erroneous: LFUN_PASTE should be called with
+// buffer number, not data to be inserted -- MV 26.02.2006
 void LCursor::paste(string const & data)
 {
        if (!data.empty())
@@ -707,12 +720,12 @@
        string const safe = lyx::cap::grabAndEraseSelection(*this);
        plainInsert(t);
        // enter the new inset and move the contents of the selection if 
possible
-       if (t->isActive()) {
+       if (t->isActive() && !safe.empty()) {
                posLeft();
                // be careful here: don't use 'pushLeft(t)' as this we need to
                // push the clone, not the original
                pushLeft(*nextInset());
-               paste(safe);
+               insert(safe);
        }
 }
 
Index: mathed/math_nestinset.C
===================================================================
--- mathed/math_nestinset.C     (revision 13276)
+++ mathed/math_nestinset.C     (working copy)
@@ -888,13 +888,7 @@
                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);
+               cur.niceInsert(cmd.argument);
                break;
                }
 

Attachment: pgpKbk3zWx9G9.pgp
Description: PGP signature

Reply via email to