]> git.lyx.org Git - features.git/commitdiff
Fix bug 5765: http://bugzilla.lyx.org/show_bug.cgi?id=5765.
authorVincent van Ravesteijn <vfr@lyx.org>
Thu, 26 Feb 2009 21:29:19 +0000 (21:29 +0000)
committerVincent van Ravesteijn <vfr@lyx.org>
Thu, 26 Feb 2009 21:29:19 +0000 (21:29 +0000)
[visual cursor] Crash when cutting a figure caption and moving the cursor.

Avoid negative positions.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@28629 a592a061-630c-0410-9148-cb99ea01b6c8

src/Cursor.cpp

index cd05e2564562205806ce2d9fa32d35139a0821b5..88a2092f3405c96398635673fe11a9d80c3e3c19 100644 (file)
@@ -644,7 +644,7 @@ void Cursor::getSurroundingPos(pos_type & left_pos, pos_type & right_pos)
        // The cursor is painted *before* the character at pos(), or, if 'boundary'
        // is true, *after* the character at (pos() - 1). So we already have one
        // known position around the cursor:
-       pos_type known_pos = boundary() ? pos() - 1 : pos();
+       pos_type known_pos = boundary() && pos() > 0 ? pos() - 1 : pos();
        
        // edge case: if we're at the end of the paragraph, things are a little 
        // different (because lastpos is a position which does not really "exist"