X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FCursorSlice.cpp;h=0e46c0781fc760ac8e8783fcd099011db555151f;hb=4db3e641ed6765e005343010cb90ee8af26f8f99;hp=c4b1c72f80d803868a01b39e226e66cf1cba4841;hpb=f1cba8ff64b369792fd49f5ddf90e8126ab476ac;p=lyx.git diff --git a/src/CursorSlice.cpp b/src/CursorSlice.cpp index c4b1c72f80..0e46c0781f 100644 --- a/src/CursorSlice.cpp +++ b/src/CursorSlice.cpp @@ -23,8 +23,10 @@ #include "insets/Inset.h" #include "mathed/InsetMath.h" -#include "mathed/MathData.h" +#include "mathed/MathMacro.h" +#include "support/ExceptionMessage.h" +#include "support/gettext.h" #include "support/lassert.h" #include @@ -42,7 +44,7 @@ CursorSlice::CursorSlice() CursorSlice::CursorSlice(Inset & p) : inset_(&p), idx_(0), pit_(0), pos_(0) { - LASSERT(inset_, /**/); + LBUFERR(inset_); } @@ -60,9 +62,11 @@ Paragraph & CursorSlice::paragraph() const pos_type CursorSlice::lastpos() const { - LASSERT(inset_, /**/); - return inset_->asInsetMath() ? cell().size() - : (text()->empty() ? 0 : paragraph().size()); + LBUFERR(inset_); + InsetMath const * math = inset_->asInsetMath(); + bool paramless_macro = math && math->asMacro() && !math->asMacro()->nargs(); + return math ? (paramless_macro ? 0 : cell().size()) + : (text()->empty() ? 0 : paragraph().size()); } @@ -76,6 +80,8 @@ pit_type CursorSlice::lastpit() const CursorSlice::row_type CursorSlice::row() const { + // LASSERT: This should only ever be called from an InsetMath. + // Should we crash in release mode, though, or try to continue? LASSERT(asInsetMath(), /**/); return asInsetMath()->row(idx_); } @@ -83,6 +89,8 @@ CursorSlice::row_type CursorSlice::row() const CursorSlice::col_type CursorSlice::col() const { + // LASSERT: This should only ever be called from an InsetMath. + // Should we crash in release mode, though, or try to continue? LASSERT(asInsetMath(), /**/); return asInsetMath()->col(idx_); } @@ -108,7 +116,7 @@ void CursorSlice::forwardPos() // otherwise move on one cell //lyxerr << "... next idx" << endl; - LASSERT(idx_ < nargs(), /**/); + LASSERT(idx_ < nargs(), return); ++idx_; pit_ = 0; @@ -118,7 +126,7 @@ void CursorSlice::forwardPos() void CursorSlice::forwardIdx() { - LASSERT(idx_ < nargs(), /**/); + LASSERT(idx_ < nargs(), return); ++idx_; pit_ = 0; @@ -146,7 +154,7 @@ void CursorSlice::backwardPos() return; } - LASSERT(false, /**/); + LATTEST(false); } @@ -185,7 +193,8 @@ bool operator<(CursorSlice const & p, CursorSlice const & q) if (p.inset_ != q.inset_) { LYXERR0("can't compare cursor and anchor in different insets\n" << "p: " << p << '\n' << "q: " << q); - LASSERT(false, /**/); + // It should be safe to continue, just registering the error. + LASSERT(false, return false); } if (p.idx_ != q.idx_) return p.idx_ < q.idx_;