On Mon, 2006-01-23 at 09:59 +0100, Jean-Marc Lasgouttes wrote:
> >>>>> "Martin" == Martin Vermeer <[EMAIL PROTECTED]> writes:
>
> Martin> Ah yes... thanks. The attached should be OK in this respect.
>
>
> I do not think so:
> - for ( ; it != et; it.forwardPos()) {
> + for ( ; it != et && it.pit() < from + 2; it.forwardPos()) {
>
> This code compares pits, but you do not know whether they refer to the
> same inset.Grrr... they should hang whoever invented pits. The attached ought to be safe... and still works for me ;-) - Martin
Index: cursor.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/cursor.C,v
retrieving revision 1.142
diff -u -p -r1.142 cursor.C
--- cursor.C 19 Jan 2006 15:49:20 -0000 1.142
+++ cursor.C 23 Jan 2006 09:55:42 -0000
@@ -162,15 +168,14 @@ namespace {
/// moves position closest to (x, y) in given box
bool bruteFind3(LCursor & cur, int x, int y, bool up)
{
+ // Scans three paragraphs in main document around cursor
BufferView & bv = cur.bv();
int ylow = up ? 0 : y + 1;
int yhigh = up ? y - 1 : bv.workHeight();
int xlow = 0;
int xhigh = bv.workWidth();
-// FIXME: bit more work needed to get 'from' and 'to' right.
pit_type from = cur.bottom().pit();
- //pit_type to = cur.bottom().pit();
//lyxerr << "Pit start: " << from << endl;
//lyxerr << "bruteFind3: x: " << x << " y: " << y
@@ -179,12 +184,15 @@ namespace {
// << endl;
InsetBase & inset = bv.buffer()->inset();
DocIterator it = doc_iterator_begin(inset);
- it.pit() = from;
DocIterator et = doc_iterator_end(inset);
+ // Previous paragraph:
+ it.pit() = std::max(from - 1, 0);
double best_dist = std::numeric_limits<double>::max();
DocIterator best_cursor = et;
+ for (et = it; et.pit() < from + 2; et.forwardPosNoDescend());
+
for ( ; it != et; it.forwardPos()) {
// avoid invalid nesting when selecting
if (bv_funcs::status(&bv, it) == bv_funcs::CUR_INSIDE
@@ -1032,9 +1040,7 @@ bool LCursor::goUpDown(bool up)
// no such inset found, just take something "above"
if (!popLeft()) {
//lyxerr << "updown: popleft failed (strange case)" << endl;
- int ylow = up ? 0 : yo + 1;
- int yhigh = up ? yo - 1 : bv().workHeight();
- return bruteFind(*this, xo, yo, 0, bv().workWidth(), ylow, yhigh);
+ return bruteFind3(*this, xo, yo, up);
}
// any improvement so far?
signature.asc
Description: This is a digitally signed message part
