>>>>> "Martin" == Martin Vermeer <[EMAIL PROTECTED]> writes:
Martin> Note BTW that not only does cursor up do the same thing, but Martin> pressing page up/down in an empty paragraph (_without_ any Martin> inset, without any noindent, irrespective of empty par Martin> history) will crash lyx: This is another problem. It happens because dEPM removes a paragraph from paragraph list, without updating the coordcache. Here are first the solutions that ought to work but I did not try: * In getPitNearY, it is the following test that crashes: if (it->first >= pit && int(it->second.y_) - int(pars_[it->first].ascent()) <= y) { pit = it->first; yy = it->second.y_; } Obvious solution is to test that it->first < pars_.size(). It solves the crash, but other similar ones may happen elsewhere. * dEPM could remove a paragraph from the coordcache when it erases it. Requires using startUpdating, though. Note that these two solutions mean that we use wrong values for coordcache, but we probably do not care. The solution I propose (which is the first one I thought about) is attached. Basically, we do an update before calling cursorDown. I would have preferred a simple metrics(), but this is not available ouside of BufferView::Pimpl (should I make it available?). The same should be done for page up. Thoughts? I'd really appreciate comments on that, since I do not understand this code very well. JMarc
Index: src/lyxtext.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxtext.h,v retrieving revision 1.327 diff -u -p -r1.327 lyxtext.h --- src/lyxtext.h 20 Sep 2005 08:31:34 -0000 1.327 +++ src/lyxtext.h 7 Oct 2005 08:49:50 -0000 @@ -176,8 +176,8 @@ public: void recUndo(pit_type first, pit_type last) const; /// void recUndo(pit_type first) const; - /// - void setCursorFromCoordinates(LCursor & cur, int x, int y); + /// returns true if par was empty and was removed + bool setCursorFromCoordinates(LCursor & cur, int x, int y); /// InsetBase * editXY(LCursor & cur, int x, int y); /// Move cursor one line up. Index: src/text.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text.C,v retrieving revision 1.631 diff -u -p -r1.631 text.C --- src/text.C 5 Oct 2005 08:41:22 -0000 1.631 +++ src/text.C 7 Oct 2005 08:49:50 -0000 @@ -2315,7 +2315,7 @@ pos_type LyXText::x2pos(pit_type pit, in // x,y are screen coordinates // sets cursor only within this LyXText -void LyXText::setCursorFromCoordinates(LCursor & cur, int const x, int const y) +bool LyXText::setCursorFromCoordinates(LCursor & cur, int const x, int const y) { pit_type pit = getPitNearY(y); int yy = theCoords.get(this, pit).y_ - pars_[pit].ascent(); @@ -2354,5 +2354,5 @@ void LyXText::setCursorFromCoordinates(L << " pos: " << pos << endl; - setCursor(cur, pit, pos, true, bound); + return setCursor(cur, pit, pos, true, bound); } Index: src/text3.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text3.C,v retrieving revision 1.309 diff -u -p -r1.309 text3.C --- src/text3.C 3 Oct 2005 10:53:40 -0000 1.309 +++ src/text3.C 7 Oct 2005 08:49:50 -0000 @@ -211,8 +211,10 @@ bool LyXText::cursorNext(LCursor & cur) lyx::pit_type cpar = cur.pit(); int x = cur.x_target(); - setCursorFromCoordinates(cur, x, cur.bv().workHeight() - 1); - bool updated = cursorDown(cur); + bool updated = setCursorFromCoordinates(cur, x, cur.bv().workHeight() - 1); + if (updated) + cur.bv().update(); + updated |= cursorDown(cur); if (cpar == cur.pit() && cpos == cur.pos()) { // we have a row which is taller than the workarea. The