Juergen Spitzmueller wrote:
> I think I found it: bruteFind in cursor.C
Attached is what I came up with. Now the cursor does not move into collapsed
insets anymore, and the crash is fixed as well.
Instead, we could implement a dociterator::forwardPosIgnoreCollapsed() method,
which basically contains the same code. Would it be worth it?
Jürgen
Index: src/bufferview_funcs.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/bufferview_funcs.C,v
retrieving revision 1.157
diff -p -u -r1.157 bufferview_funcs.C
--- src/bufferview_funcs.C 10 Nov 2005 08:28:06 -0000 1.157
+++ src/bufferview_funcs.C 27 Jan 2006 11:00:49 -0000
@@ -163,11 +163,7 @@ Point coordOffset(DocIterator const & di
CursorSlice const & sl = dit[i];
int xx = 0;
int yy = 0;
- //FIXME: the check for asMathInset() shouldn't be necessary
- // but math insets do not return a sensible editable() state yet.
- if (sl.inset().asMathInset()
- || sl.inset().editable() == InsetBase::HIGHLY_EDITABLE)
- sl.inset().cursorPos(sl, boundary && ((i+1) == dit.depth()), xx, yy);
+ sl.inset().cursorPos(sl, boundary && ((i+1) == dit.depth()), xx, yy);
x += xx;
y += yy;
//lyxerr << "LCursor::getPos, i: "
Index: src/cursor.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/cursor.C,v
retrieving revision 1.142
diff -p -u -r1.142 cursor.C
--- src/cursor.C 19 Jan 2006 15:49:20 -0000 1.142
+++ src/cursor.C 27 Jan 2006 11:00:51 -0000
@@ -128,10 +128,20 @@ namespace {
double best_dist = std::numeric_limits<double>::max();;
DocIterator best_cursor = et;
- for ( ; it != et; it.forwardPos()) {
+ while (it != et) {
// avoid invalid nesting when selecting
if (bv_funcs::status(&cursor.bv(), it) == bv_funcs::CUR_INSIDE
&& (!cursor.selection() || positionable(it, cursor.anchor_))) {
+ // do not consider collapsed insets
+ if (&it.inset() && (!it.inset().asMathInset()
+ && it.inset().editable() != InsetBase::HIGHLY_EDITABLE)) {
+ // leave inset and jump over inset as a whole
+ it.pop_back();
+ // 'top' is invalid now...
+ if (!it.empty())
+ ++it.top().pos();
+ continue;
+ }
Point p = bv_funcs::getPos(it, false);
int xo = p.x_;
int yo = p.y_;
@@ -148,6 +158,7 @@ namespace {
}
}
}
+ it.forwardPos();
}
if (best_cursor != et) {