Andre Poenitz wrote: >> I think this has been reported before... > > Indeed. And I haven't had time to fix it so far. > > The problem is most likely an off-by-one (or two) bug in accessing > the cells of the script inset. A while ago, cell 0 was always the > subscript, cell 1 the superscript and cell 2 the base and there was > some extra code to handle 'missing' super/subscripts. Such code was > also necessary in the DocIterator, and it clearly doesn't belong > there. > > So now we have the base (which must exist) in cell 0. If there are > both sub- and superscript, the superscipt is in 1 and the subscript > in 2, and if there is just one of them, it's in cell 1. 'nargs' > returns now 2 or 3 (not always 3 as formerly) > > The access should go through some wrapper functions there > (up/down(?), don't have sources here...) and it looks like I f* > something up there.
Here's one error, although I think that nargs() == 1 is possible which would cause the 'c' part of 'a?b:c' to fail also... MathArray const & MathScriptInset::down() const { - return nargs() == 2 ? cell(2) : cell(1); + return nargs() == 3 ? cell(2) : cell(1); } MathArray & MathScriptInset::down() { - return nargs() == 2 ? cell(2) : cell(1); + return nargs() == 3 ? cell(2) : cell(1); } Here, should you test nargs()? void MathScriptInset::notifyCursorLeaves(idx_type idx) { MathNestInset::notifyCursorLeaves(idx); // remove empty scripts if possible - if (idx == 2 && cell(2).empty()) { + if (idx == 2 && nargs() > 2 && cell(2).empty()) { removeScript(false); // must be a subscript... - } else if (idx == 1 && cell(1).empty()) { + } else if (idx == 1 && nargs() > 1 && cell(1).empty()) { if (nargs() == 2) { cell_1_is_up_ = false; cell(1) = cell(2); cells_.pop_back(); } else if (nargs() == 1) { cells_.pop_back(); } } } -- Angus