#include "Text.h"
#include "BranchList.h"
-#include "FloatList.h"
-#include "FuncStatus.h"
#include "Buffer.h"
-#include "buffer_funcs.h"
#include "BufferParams.h"
#include "BufferView.h"
-#include "Changes.h"
#include "Cursor.h"
#include "CutAndPaste.h"
#include "DispatchResult.h"
-#include "ErrorList.h"
#include "factory.h"
+#include "FloatList.h"
+#include "FuncStatus.h"
#include "FuncRequest.h"
#include "InsetList.h"
#include "Intl.h"
#include "support/lassert.h"
#include "support/limited_stack.h"
#include "support/lstrings.h"
-#include "support/lyxalgo.h"
-#include "support/lyxtime.h"
-#include "support/os.h"
#include "support/regex.h"
#include "mathed/InsetMathHull.h"
}
bool gotsel = false;
+ bool move_layout = false;
if (cur.selection()) {
if (cmd.action() == LFUN_INDEX_INSERT)
copySelectionToTemp(cur);
* FIXME: this does not work as expected when change tracking is on
* However, we do not really know what to do in this case.
*/
- if (cur.paragraph().empty() && !inset->forcePlainLayout())
+ if (cur.paragraph().empty() && !inset->forcePlainLayout()) {
cur.paragraph().setPlainOrDefaultLayout(bparams.documentClass());
+ move_layout = true;
+ }
}
cur.clearSelection();
gotsel = true;
inset_text->fixParagraphsFont();
cur.pos() = 0;
cur.pit() = 0;
+ /* If the containing paragraph has kept its layout, reset the
+ * layout of the first paragraph of the inset.
+ */
+ if (!move_layout)
+ cur.paragraph().setPlainOrDefaultLayout(bparams.documentClass());
// FIXME: what does this do?
if (cmd.action() == LFUN_FLEX_INSERT)
return true;
};
-static void insertSeparator(Cursor & cur, depth_type const depth)
+static void insertSeparator(Cursor const & cur, depth_type const depth)
{
Buffer & buf = *cur.buffer();
lyx::dispatch(FuncRequest(LFUN_PARAGRAPH_BREAK));
cur.resetAnchor();
} else {
cutSelection(cur, false);
+ cur.setCurrentFont();
singleParUpdate = false;
}
moveCursor(cur, false);
// and the selection is not really cut,
// move cursor before selection (#11630)
cur.setCursor(dit);
+ cur.setCurrentFont();
singleParUpdate = false;
}
break;
Paragraph const & nextpar = lastpar ? par : pars_[pit + 1];
pit_type prev = pit > 0 ? depthHook(pit, par.getDepth()) : pit;
if (prev < pit && cur.pos() == par.beginOfBody()
- && !par.size() && !par.isEnvSeparator(cur.pos())
+ && par.empty() && !par.isEnvSeparator(cur.pos())
&& !par.layout().keepempty
&& !par.layout().isCommand()
&& pars_[prev].layout() != par.layout()
if (change_layout) {
setLayout(cur, layout);
if (cur.pit() > 0 && !ignoreautonests) {
+ pit_type prev_pit = cur.pit() - 1;
+ depth_type const cur_depth = pars_[cur.pit()].getDepth();
+ // Scan for the previous par on same nesting level
+ while (prev_pit > 0 && pars_[prev_pit].getDepth() > cur_depth)
+ --prev_pit;
set<docstring> const & autonests =
- pars_[cur.pit() - 1].layout().autonests();
+ pars_[prev_pit].layout().autonests();
set<docstring> const & autonested =
pars_[cur.pit()].layout().isAutonestedBy();
if (autonests.find(layout) != autonests.end()
// "auto_region_delete", which defaults to
// true (on).
- if (lyxrc.auto_region_delete && cur.selection())
+ if (lyxrc.auto_region_delete && cur.selection()) {
cutSelection(cur, false);
+ cur.setCurrentFont();
+ }
cur.clearSelection();
for (char_type c : cmd.argument())
cur.buffer()->params().documentClass().insetLayout(from_utf8(s));
if (il.lyxtype() != InsetLayout::CHARSTYLE &&
il.lyxtype() != InsetLayout::CUSTOM &&
- il.lyxtype() != InsetLayout::ELEMENT &&
il.lyxtype ()!= InsetLayout::STANDARD)
enable = false;
break;
// FIXME: an item inset would make things much easier.
-bool Text::inDescriptionItem(Cursor & cur) const
+bool Text::inDescriptionItem(Cursor const & cur) const
{
- Paragraph & par = cur.paragraph();
+ Paragraph const & par = cur.paragraph();
pos_type const pos = cur.pos();
pos_type const body_pos = par.beginOfBody();