commit ba0f28a09b5d2037b836395400e8520801618647 Author: Richard Kimberly Heck <rikih...@lyx.org> Date: Wed Apr 25 22:22:36 2018 -0400
Simplify some code now that we don't need it for indexes. This has the effect that inserting nomenclature entries does not cut the selection (implicit or explicit) but rather copies it, which seems to me to make a lot more sense. If anyone objects, let me know. --- src/Text.h | 2 +- src/Text2.cpp | 17 +++++------------ src/Text3.cpp | 8 +++++--- 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/src/Text.h b/src/Text.h index 4fc86ff..f09acc8 100644 --- a/src/Text.h +++ b/src/Text.h @@ -112,7 +112,7 @@ public: /// ??? /// FIXME: replace Cursor with DocIterator. - docstring getStringToIndex(Cursor const & cur); + docstring getStringForDialog(Cursor & cur); /// Convert the paragraphs to a string. /// \param AsStringParameter options. This can contain any combination of diff --git a/src/Text2.cpp b/src/Text2.cpp index 8eb70f8..bbd30a7 100644 --- a/src/Text2.cpp +++ b/src/Text2.cpp @@ -432,7 +432,7 @@ void Text::toggleFree(Cursor & cur, Font const & font, bool toggleall) } -docstring Text::getStringToIndex(Cursor const & cur) +docstring Text::getStringForDialog(Cursor & cur) { LBUFERR(this == cur.text()); @@ -442,17 +442,10 @@ docstring Text::getStringToIndex(Cursor const & cur) // Try implicit word selection. If there is a change // in the language the implicit word selection is // disabled. - Cursor tmpcur = cur; - selectWord(tmpcur, PREVIOUS_WORD); - - if (!tmpcur.selection()) - cur.message(_("Nothing to index!")); - else if (tmpcur.selBegin().pit() != tmpcur.selEnd().pit()) - cur.message(_("Cannot index more than one paragraph!")); - else - return tmpcur.selectionAsString(false); - - return docstring(); + selectWordWhenUnderCursor(cur, WHOLE_WORD); + docstring const & retval = cur.selectionAsString(false); + cur.clearSelection(); + return retval; } diff --git a/src/Text3.cpp b/src/Text3.cpp index 22f827e..83d197a 100644 --- a/src/Text3.cpp +++ b/src/Text3.cpp @@ -2128,9 +2128,11 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) case LFUN_NOMENCL_INSERT: { InsetCommandParams p(NOMENCL_CODE); - if (cmd.argument().empty()) - p["symbol"] = bv->cursor().innerText()->getStringToIndex(bv->cursor()); - else + if (cmd.argument().empty()) { + p["symbol"] = + bv->cursor().innerText()->getStringForDialog(bv->cursor()); + cur.clearSelection(); + } else p["symbol"] = cmd.argument(); string const data = InsetCommand::params2string(p); bv->showDialog("nomenclature", data);