From b4d20b81afd54c4a2586419a0dd629f4baa615e3 Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Wed, 23 Aug 2006 10:57:49 +0000 Subject: [PATCH] Handle properly script insets which nucleus has more than one element (like {a'}^{2}). (froward port from 14802) * src/mathed/math_nestinset.C (script): when creating a script inset, handle specially previous atom if it is a MathBraceInset (this is used in interactive input). * src/mathed/math_parser.C (parse1): when creating a script inset, handle specially previous atom if it is a MathBraceInset (this is used in parsing phase). * src/mathed/math_scriptinset.C (write): put nucleus into braces if it contains more than one element or is itself a script inset. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@14819 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/mathed/math_nestinset.C | 6 ++++++ src/mathed/math_parser.C | 7 +++---- src/mathed/math_scriptinset.C | 6 +++++- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/mathed/math_nestinset.C b/src/mathed/math_nestinset.C index fd0cef3b48..a747ee742a 100644 --- a/src/mathed/math_nestinset.C +++ b/src/mathed/math_nestinset.C @@ -1368,6 +1368,12 @@ bool MathNestInset::script(LCursor & cur, bool up, string const & } --cur.pos(); MathScriptInset * inset = cur.nextAtom().nucleus()->asScriptInset(); + // special handling of {}-bases + // is this always correct? + if (inset->nuc().size() == 1 + && inset->nuc().back()->asBraceInset()) + inset->nuc() = inset->nuc().back()->asNestInset()->cell(0); + cur.push(*inset); cur.idx() = 1; cur.pos() = 0; diff --git a/src/mathed/math_parser.C b/src/mathed/math_parser.C index 6aea310a37..6d4584c674 100644 --- a/src/mathed/math_parser.C +++ b/src/mathed/math_parser.C @@ -813,10 +813,9 @@ void Parser::parse1(MathGridInset & grid, unsigned flags, MathScriptInset * p = cell->back().nucleus()->asScriptInset(); // special handling of {}-bases // is this always correct? - // It appears that this is wrong (Dekel) - //if (p->nuc().size() == 1 && p->nuc().back()->asNestInset() && - // p->nuc().back()->extraBraces()) - // p->nuc() = p->nuc().back()->asNestInset()->cell(0); + if (p->nuc().size() == 1 + && p->nuc().back()->asBraceInset()) + p->nuc() = p->nuc().back()->asNestInset()->cell(0); parse(p->cell(p->idxOfScript(up)), FLAG_ITEM, mode); if (limits) { p->limits(limits); diff --git a/src/mathed/math_scriptinset.C b/src/mathed/math_scriptinset.C index 2983a56120..6032f248e1 100644 --- a/src/mathed/math_scriptinset.C +++ b/src/mathed/math_scriptinset.C @@ -420,7 +420,11 @@ bool MathScriptInset::idxUpDown(LCursor & cur, bool up) const void MathScriptInset::write(WriteStream & os) const { if (nuc().size()) { - os << nuc(); + if (nuc().size() == 1 + && ! nuc().begin()->nucleus()->asScriptInset()) + os << nuc(); + else + os << '{' << nuc() << '}'; //if (nuc().back()->takesLimits()) { if (limits_ == -1) os << "\\nolimits ";