]> git.lyx.org Git - lyx.git/commitdiff
bug 1825 make sure that we do not return a pos that is not on the row
authorLars Gullik Bjønnes <larsbj@gullik.org>
Fri, 15 Jul 2005 12:56:23 +0000 (12:56 +0000)
committerLars Gullik Bjønnes <larsbj@gullik.org>
Fri, 15 Jul 2005 12:56:23 +0000 (12:56 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10206 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/text.C
src/text2.C

index 81d2d86d4e265822d7fd64ed18a5817a576d8795..f50c4d3816f00dfff9a36113dfecf647c4416ee9 100644 (file)
@@ -1,5 +1,10 @@
 2005-07-15    <lgb@tandberg.net>
 
+       * text.C (setCursorFromCoordinates): add a debug statement
+
+       * text2.C (getColumnNearX): bug 1825 make sure that we don't
+       return a pos that is not on the row
+
        * output_latex.C (TeXDeeper): get rid of potential dereferencing
        of past the end iterator
 
index d43486d46089c3dd48654d2152b77bcd35e27298..61c3dd8500373b5fd8bbdccfca1d8d3033e9677e 100644 (file)
@@ -2304,5 +2304,12 @@ void LyXText::setCursorFromCoordinates(LCursor & cur, int const x, int const y)
        bool bound = false;
        int xx = x;
        pos_type const pos = row.pos() + getColumnNearX(pit, row, xx, bound);
+
+        lyxerr[Debug::DEBUG]
+                << BOOST_CURRENT_FUNCTION
+                << ": setting cursor pit: " << pit
+                << " pos: " << pos
+                << endl;
+        
        setCursor(cur, pit, pos, true, bound);
 }
index b993d6e6a90b9783d3a3f17f7be3c462984f0541..75d4f4f8756b24e73832e406abd461031b9be211 100644 (file)
@@ -61,6 +61,7 @@ using lyx::pos_type;
 using std::endl;
 using std::ostringstream;
 using std::string;
+using std::min;
 
 
 LyXText::LyXText(BufferView * bv)
@@ -854,7 +855,11 @@ pos_type LyXText::getColumnNearX(pit_type const pit,
        }
 
        x = int(tmpx) + xo;
-       return c - row.pos();
+
+        if (end == par.size())
+                return c - row.pos();
+
+        return min(c - row.pos(), end - 1 - row.pos());
 }