bug 1825 make sure that we do not return a pos that is not on the row

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10206 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 2005-07-15 12:56:23 +00:00
parent c1ef1ac5e4
commit 8355663e97
3 changed files with 18 additions and 1 deletions

View 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

View 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);
}

View 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());
}