Fix bug #6033: Initial character sometimes eaten by math-insert

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30246 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Enrico Forestieri 2009-06-23 18:01:31 +00:00
parent 042c5bf425
commit 5415144621
2 changed files with 11 additions and 2 deletions

View File

@ -1529,6 +1529,14 @@ void LyXAction::init()
* \li Action: Inserts math objects and symbols.
* \li Syntax: math-insert <ARG>
* \li Params: <ARG>: Symbol or LaTeX code to be inserted.
* \li Notion: When <ARG> is a _single_ math inset with more than one cell
(such as "x_y^z" or "\frac{x}{y}"), the content of cell(0) is
replaced by the current selection (only works if the selection
is in mathed). As an example, if "abc" is selected in mathed,
"math-insert \frac{x}{y}" replaces "abc" with "\frac{abc}{y}",
and "math-insert x_y^z" replaces "abc" with "abc_y^z".
If nothing is selected (or the selection is not in mathed),
math-insert works as expected.
* \endvar
*/
{ LFUN_MATH_INSERT, "math-insert", Noop, Math },

View File

@ -1131,8 +1131,9 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd)
else {
MathData ar;
asArray(cmd.argument(), ar);
if (ar.size() == 1 && ar[0]->asNestInset()
&& ar[0]->asNestInset()->nargs() > 1)
if (cur.selection() && ar.size() == 1
&& ar[0]->asNestInset()
&& ar[0]->asNestInset()->nargs() > 1)
handleNest(cur, ar[0]);
else
cur.niceInsert(cmd.argument());