On Thu, Nov 03, 2005 at 07:22:56PM +0100, Jean-Marc Lasgouttes wrote:
> >>>>> "Martin" == Martin Vermeer <[EMAIL PROTECTED]> writes:
> 
> Martin> Your observation. that the "painting" of the selection somehow
> Martin> keeps begin and end of the selection on the same depth, is
> Martin> valid though. I wonder where that happens.
> 
> It is in LyXText::drawSelection. The code is dubious, however (the two
> instances of it have the same cursor treatment).

Yes, I see your worry. But it seems to work right.

I looked at the slices cur.selBegin and cur.selEnd, but don't know what
to do with them. Probably nothing. It's the iterators that cause this
bug.

The attached patch is perhaps more what you had in mind. It forces the
selectionBegin and selectionEnd iterators to be of the same depth. Works
for both cases: selecting to the left and to the right. I believe that
covers all bases.

- Martin

Index: cursor.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/cursor.C,v
retrieving revision 1.138
diff -u -p -r1.138 cursor.C
--- cursor.C    12 Oct 2005 18:44:52 -0000      1.138
+++ cursor.C    3 Nov 2005 19:48:19 -0000
@@ -438,7 +438,9 @@ DocIterator LCursor::selectionBegin() co
 {
        if (!selection())
                return *this;
-       return anchor() < top() ? anchor_ : *this;
+       DocIterator di = (anchor() < top() ? anchor_ : *this);
+       di.resize(depth());
+       return di;
 }
 
 
@@ -446,7 +448,9 @@ DocIterator LCursor::selectionEnd() cons
 {
        if (!selection())
                return *this;
-       return anchor() > top() ? anchor_ : *this;
+       DocIterator di = (anchor() > top() ? anchor_ : *this);
+       di.resize(depth());
+       return di;
 }
 
 

Attachment: pgp1aRAZfD599.pgp
Description: PGP signature

Reply via email to