// Don't use forwardChar here as ditend might have
// pos() == lastpos() and forwardChar would miss it.
// Can't use forwardPos either as this descends into
- // nested insets.
+ // nested insets.
for (; dit != ditend; dit.forwardPosNoDescend()) {
if (dit.pos() != dit.lastpos()) {
LyXFont f = getFont(dit.paragraph(), dit.pos());
}
-string LyXText::getStringToIndex(LCursor & cur)
+string LyXText::getStringToIndex(LCursor const & cur)
{
BOOST_ASSERT(this == cur.text());
- // Try implicit word selection
- // If there is a change in the language the implicit word selection
- // is disabled.
- CursorSlice const reset_cursor = cur.top();
- bool const implicitSelection =
- selectWordWhenUnderCursor(cur, lyx::PREVIOUS_WORD);
string idxstring;
- if (!cur.selection())
- cur.message(_("Nothing to index!"));
- else if (cur.selBegin().pit() != cur.selEnd().pit())
- cur.message(_("Cannot index more than one paragraph!"));
- else
+ if (cur.selection()) {
idxstring = cur.selectionAsString(false);
-
- // Reset cursors to their original position.
- cur.top() = reset_cursor;
- cur.resetAnchor();
-
- // Clear the implicit selection.
- if (implicitSelection)
- cur.clearSelection();
+ } else {
+ // Try implicit word selection. If there is a change
+ // in the language the implicit word selection is
+ // disabled.
+ LCursor tmpcur = cur;
+ selectWord(tmpcur, lyx::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
+ idxstring = tmpcur.selectionAsString(false);
+ }
return idxstring;
}
c = end - 1;
}
// Air gap below display inset:
- if (row.pos() < end && c >= end && par.isInset(end - 1)
+ if (row.pos() < end && c >= end && par.isInset(end - 1)
&& par.getInset(end - 1)->display()) {
c = end - 1;
}