Cursor::Cursor(BufferView & bv)
: DocIterator(&bv.buffer()), bv_(&bv), anchor_(),
x_target_(-1), textTargetOffset_(0),
- selection_(false), mark_(false), logicalpos_(false),
- current_font(inherit_font)
+ selection_(false), mark_(false), word_selection_(false),
+ logicalpos_(false), current_font(inherit_font)
{}
void Cursor::clearSelection()
{
setSelection(false);
+ setWordSelection(false);
setMark(false);
resetAnchor();
}
}
-void Cursor::niceInsert(docstring const & t, Parse::flags f)
+void Cursor::niceInsert(docstring const & t, Parse::flags f, bool enter)
{
MathData ar(buffer());
asArray(t, ar, f);
- if (ar.size() == 1)
+ if (ar.size() == 1 && (enter || selection()))
niceInsert(ar[0]);
else
insert(ar);
macroModeClose();
docstring const safe = cap::grabAndEraseSelection(*this);
plainInsert(t);
- // enter the new inset and move the contents of the selection if possible
+ // If possible, enter the new inset and move the contents of the selection
if (t->isActive()) {
posBackward();
// be careful here: don't use 'pushBackward(t)' as this we need to
// notify everything on top of the common part in old cursor,
// but stop if the inset claims the cursor to be invalid now
for (size_type j = i; j < old.depth(); ++j) {
- Cursor insetPos = old;
- insetPos.cutOff(j);
- if (old[j].inset().notifyCursorLeaves(insetPos, cur))
+ Cursor inset_pos = old;
+ inset_pos.cutOff(j);
+ if (old[j].inset().notifyCursorLeaves(inset_pos, cur))
return true;
}