mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
OK, so that version of revert_inset_preview wasn't so good. Restore the
complicated code, but note its issues. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36061 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
49a2a04963
commit
f9f0c57da2
@ -1425,54 +1425,60 @@ def revert_inset_preview(document):
|
|||||||
i += 1
|
i += 1
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
# This has several issues.
|
||||||
|
# We need to do something about the layouts inside InsetPreview.
|
||||||
|
# If we just leave the first one, then we have something like:
|
||||||
|
# \begin_layout Standard
|
||||||
|
# ...
|
||||||
|
# \begin_layout Standard
|
||||||
|
# and we get a "no \end_layout" error. So something has to be done.
|
||||||
|
# Ideally, we would check if it is the same as the layout we are in.
|
||||||
|
# If so, we just remove it; if not, we end the active one. But it is
|
||||||
|
# not easy to know what layout we are in, due to depth changes, etc,
|
||||||
|
# and it is not clear to me how much work it is worth doing. In most
|
||||||
|
# cases, the layout will probably be the same.
|
||||||
|
#
|
||||||
|
# For the same reason, we have to remove the \end_layout tag at the
|
||||||
|
# end of the last layout in the inset. Again, that will sometimes be
|
||||||
|
# wrong, but it will usually be right. To know what to do, we would
|
||||||
|
# again have to know what layout the inset is in.
|
||||||
|
|
||||||
|
blay = find_token(document.body, "\\begin_layout", i, iend)
|
||||||
|
if blay == -1:
|
||||||
|
document.warning("Can't find layout for preview inset!")
|
||||||
|
# always do the later one first...
|
||||||
del document.body[iend]
|
del document.body[iend]
|
||||||
del document.body[i]
|
del document.body[i]
|
||||||
|
# deletions mean we do not need to reset i
|
||||||
|
continue
|
||||||
|
|
||||||
# This does not work. The problem is that the last layout may not be
|
# This is where we would check what layout we are in.
|
||||||
# standard, in which case the material following the preview, which
|
# The check for Standard is definitely wrong.
|
||||||
# might be in this same paragraph, will now be in whatever that was.
|
#
|
||||||
# Moreover, the right action might depend upon what layout we are in,
|
# lay = document.body[blay].split(None, 1)[1]
|
||||||
# and that is not easy to find out. It is much harder to fix that kind
|
# if lay != oldlayout:
|
||||||
# of problem than to remove a paragraph break.
|
# # record a boolean to tell us what to do later....
|
||||||
# So I am disabling all of this for now, at least. If someone wants to
|
# # better to do it later, since (a) it won't mess up
|
||||||
# fix it, then feel free.
|
# # the numbering and (b) we only modify at the end.
|
||||||
|
|
||||||
## If the first layout is Standard we need to remove it, otherwise there
|
# we want to delete the last \\end_layout in this inset, too.
|
||||||
## will be paragraph breaks that shouldn't be there.
|
# note that this may not be the \\end_layout that goes with blay!!
|
||||||
#blay = find_token(document.body, "\\begin_layout", i, iend)
|
bend = find_end_of_layout(document.body, blay)
|
||||||
#if blay == -1:
|
while True:
|
||||||
#document.warning("Can't find layout for preview inset!")
|
tmp = find_token(document.body, "\\end_layout", bend + 1, iend)
|
||||||
## always do the later one first...
|
if tmp == -1:
|
||||||
#del document.body[iend]
|
break
|
||||||
#del document.body[i]
|
bend = tmp
|
||||||
## deletions mean we do not need to reset i
|
if bend == blay:
|
||||||
#continue
|
document.warning("Unable to find last layout in preview inset!")
|
||||||
#lay = document.body[blay].split(None, 1)[1]
|
del document.body[iend]
|
||||||
#if lay != "Standard":
|
del document.body[i]
|
||||||
#del document.body[iend]
|
# deletions mean we do not need to reset i
|
||||||
#del document.body[i]
|
continue
|
||||||
## deletions mean we do not need to reset i
|
# always do the later one first...
|
||||||
#continue
|
del document.body[iend]
|
||||||
|
del document.body[bend]
|
||||||
## we want to delete the last \\end_layout in this inset, too.
|
del document.body[i:blay + 1]
|
||||||
## note that this may not be the \\end_layout that goes with blay!!
|
|
||||||
#bend = find_end_of_layout(document.body, blay)
|
|
||||||
##while True:
|
|
||||||
##tmp = find_token(document.body, "\\end_layout", bend + 1, iend)
|
|
||||||
##if tmp == -1:
|
|
||||||
##break
|
|
||||||
##bend = tmp
|
|
||||||
##if bend == blay:
|
|
||||||
#if bend == -1:
|
|
||||||
#document.warning("Unable to find last layout in preview inset!")
|
|
||||||
#del document.body[iend]
|
|
||||||
#del document.body[i]
|
|
||||||
## deletions mean we do not need to reset i
|
|
||||||
#continue
|
|
||||||
## always do the later one first...
|
|
||||||
#del [iend]
|
|
||||||
#del document.body[bend]
|
|
||||||
#del document.body[i:blay + 1]
|
|
||||||
# we do not need to reset i
|
# we do not need to reset i
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user