mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-07 02:28:35 +00:00
Reset layout when inserting an inset over full paragraph(s)
1/ When inserting an inset over a selection, it makes sense if the selection covers a complete or several paragraphs to reset the layout of the paragraph that contains the inset to plain layout. In general the inner inset will have the needed layout information and it does not make sense to keep this information outside. However, when the inset forces plain layout, it does not make sense to do that and the outer layout is preserved. Some code that duplicates what is done in pasteSelectionHelper is also removed. 2/ Similarly, when dissolving an inset, do not reset the layout of the first paragraph if the inset was alone in its own paragraph. Note that this does not work as intended when change tracking is enabled. Fixes bugs #10266 and #10369.
This commit is contained in:
parent
d76cef70a0
commit
e1be71da59
10
src/Text.cpp
10
src/Text.cpp
@ -1820,6 +1820,16 @@ bool Text::dissolveInset(Cursor & cur)
|
||||
for (; it != it_end; ++it)
|
||||
it->changeLanguage(b.params(), latex_language, b.language());
|
||||
|
||||
/* the inset is the only thing in paragraph, then the layout
|
||||
* of the first paragraph of inset should be remembered.
|
||||
* 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 (inset_it.lastpos() == 1
|
||||
&& inset_it.nextInset() && !inset_it.nextInset()->forcePlainLayout())
|
||||
cur.paragraph().makeSameLayout(plist[0]);
|
||||
|
||||
pasteParagraphList(cur, plist, b.params().documentClassPtr(),
|
||||
b.errorList("Paste"));
|
||||
}
|
||||
|
@ -296,8 +296,16 @@ static bool doInsertInset(Cursor & cur, Text * text,
|
||||
if (cur.selection()) {
|
||||
if (cmd.action() == LFUN_INDEX_INSERT)
|
||||
copySelectionToTemp(cur);
|
||||
else
|
||||
else {
|
||||
cutSelectionToTemp(cur, pastesel);
|
||||
/* Move layout information inside the inset if the whole
|
||||
* paragraph and the inset allows setting layout
|
||||
* 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())
|
||||
cur.paragraph().setPlainOrDefaultLayout(bparams.documentClass());
|
||||
}
|
||||
cur.clearSelection();
|
||||
gotsel = true;
|
||||
} else if (cmd.action() == LFUN_INDEX_INSERT) {
|
||||
@ -320,24 +328,17 @@ static bool doInsertInset(Cursor & cur, Text * text,
|
||||
InsetText * inset_text = inset->asInsetText();
|
||||
if (inset_text) {
|
||||
inset_text->fixParagraphsFont();
|
||||
if (!inset_text->allowMultiPar() || cur.lastpit() == 0) {
|
||||
// reset first par to default
|
||||
cur.text()->paragraphs().begin()
|
||||
->setPlainOrDefaultLayout(bparams.documentClass());
|
||||
cur.pos() = 0;
|
||||
cur.pit() = 0;
|
||||
// Merge multiple paragraphs -- hack
|
||||
while (cur.lastpit() > 0)
|
||||
mergeParagraph(bparams, cur.text()->paragraphs(), 0);
|
||||
if (cmd.action() == LFUN_FLEX_INSERT)
|
||||
return true;
|
||||
Cursor old = cur;
|
||||
cur.leaveInset(*inset);
|
||||
if (cmd.action() == LFUN_PREVIEW_INSERT
|
||||
|| cmd.action() == LFUN_IPA_INSERT)
|
||||
// trigger preview
|
||||
notifyCursorLeavesOrEnters(old, cur);
|
||||
}
|
||||
cur.pos() = 0;
|
||||
cur.pit() = 0;
|
||||
// FIXME: what does this do?
|
||||
if (cmd.action() == LFUN_FLEX_INSERT)
|
||||
return true;
|
||||
Cursor old = cur;
|
||||
cur.leaveInset(*inset);
|
||||
if (cmd.action() == LFUN_PREVIEW_INSERT
|
||||
|| cmd.action() == LFUN_IPA_INSERT)
|
||||
// trigger preview
|
||||
notifyCursorLeavesOrEnters(old, cur);
|
||||
} else {
|
||||
cur.leaveInset(*inset);
|
||||
// reset surrounding par to default
|
||||
|
Loading…
Reference in New Issue
Block a user