mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-27 03:36:39 +00:00
fix nasty crash when selecting with up/down close to super/subcripts
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7839 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
dbd3cb42c5
commit
4dbd6214a9
@ -936,28 +936,30 @@ bool MathCursor::goUpDown(bool up)
|
|||||||
xo = targetx_;
|
xo = targetx_;
|
||||||
|
|
||||||
// try neigbouring script insets
|
// try neigbouring script insets
|
||||||
// try left
|
if (!selection()) {
|
||||||
if (hasPrevAtom()) {
|
// try left
|
||||||
MathScriptInset const * p = prevAtom()->asScriptInset();
|
if (hasPrevAtom()) {
|
||||||
if (p && p->has(up)) {
|
MathScriptInset const * p = prevAtom()->asScriptInset();
|
||||||
--pos();
|
if (p && p->has(up)) {
|
||||||
push(nextAtom());
|
--pos();
|
||||||
idx() = up; // the superscript has index 1
|
push(nextAtom());
|
||||||
pos() = size();
|
idx() = up; // the superscript has index 1
|
||||||
///lyxerr << "updown: handled by scriptinset to the left" << endl;
|
pos() = size();
|
||||||
return true;
|
//lyxerr << "updown: handled by scriptinset to the left" << endl;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// try right
|
// try right
|
||||||
if (hasNextAtom()) {
|
if (hasNextAtom()) {
|
||||||
MathScriptInset const * p = nextAtom()->asScriptInset();
|
MathScriptInset const * p = nextAtom()->asScriptInset();
|
||||||
if (p && p->has(up)) {
|
if (p && p->has(up)) {
|
||||||
push(nextAtom());
|
push(nextAtom());
|
||||||
idx() = up;
|
idx() = up;
|
||||||
pos() = 0;
|
pos() = 0;
|
||||||
///lyxerr << "updown: handled by scriptinset to the right" << endl;
|
//lyxerr << "updown: handled by scriptinset to the right" << endl;
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -977,7 +979,7 @@ bool MathCursor::goUpDown(bool up)
|
|||||||
|
|
||||||
// try to find an inset that knows better then we
|
// try to find an inset that knows better then we
|
||||||
while (1) {
|
while (1) {
|
||||||
///lyxerr << "updown: We are in " << *inset() << " idx: " << idx() << endl;
|
//lyxerr << "updown: We are in " << inset() << " idx: " << idx() << endl;
|
||||||
// ask inset first
|
// ask inset first
|
||||||
if (inset()->idxUpDown(idx(), pos(), up, targetx_)) {
|
if (inset()->idxUpDown(idx(), pos(), up, targetx_)) {
|
||||||
// try to find best position within this inset
|
// try to find best position within this inset
|
||||||
@ -987,7 +989,7 @@ bool MathCursor::goUpDown(bool up)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// no such inset found, just take something "above"
|
// no such inset found, just take something "above"
|
||||||
///lyxerr << "updown: handled by strange case" << endl;
|
//lyxerr << "updown: handled by strange case" << endl;
|
||||||
if (!popLeft())
|
if (!popLeft())
|
||||||
return
|
return
|
||||||
bruteFind(xo, yo,
|
bruteFind(xo, yo,
|
||||||
|
@ -80,8 +80,8 @@ bool operator!=(CursorPos const & p, CursorPos const & q)
|
|||||||
bool operator<(CursorPos const & p, CursorPos const & q)
|
bool operator<(CursorPos const & p, CursorPos const & q)
|
||||||
{
|
{
|
||||||
if (p.inset_ != q.inset_) {
|
if (p.inset_ != q.inset_) {
|
||||||
lyxerr << "can't compare cursor and anchor in different insets"
|
lyxerr << "can't compare cursor and anchor in different insets\n"
|
||||||
<< endl;
|
<< "p: " << p << '\n' << "q: " << q << endl;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (p.idx_ != q.idx_)
|
if (p.idx_ != q.idx_)
|
||||||
|
Loading…
Reference in New Issue
Block a user