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 && selection())
+ if (ar.size() == 1 && (enter || selection()))
niceInsert(ar[0]);
else
insert(ar);
{
macroModeClose();
docstring const safe = cap::grabAndEraseSelection(*this);
- // Enter the new inset and, if something is selected,
- // move the contents of the selection if possible.
plainInsert(t);
- if (!safe.empty() && t->isActive()) {
+ // 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
// push the clone, not the original