From 843fa219b6b7900a1fea981dd88c9d3ccfb8d1ad Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Sun, 1 Jun 2008 14:22:11 +0000 Subject: [PATCH] Fix convert_spaceinset again. The problem here is that for i in range(len(document.body)): sets the range BEFORE we do any of our manipulations. But those manipulations can make document.body longer. As a result, we can fail to test some lines. Instead, use: while i < len(document.body): and increment i in the while loop. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25050 a592a061-630c-0410-9148-cb99ea01b6c8 --- lib/lyx2lyx/lyx_1_6.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/lib/lyx2lyx/lyx_1_6.py b/lib/lyx2lyx/lyx_1_6.py index 83e082f54c..b3bad13386 100644 --- a/lib/lyx2lyx/lyx_1_6.py +++ b/lib/lyx2lyx/lyx_1_6.py @@ -1856,14 +1856,18 @@ def remove_extra_embedded_files(document): def convert_spaceinset(document): - " Convert '\\InsetSpace foo' to '\\begin_inset Space foo\n\\end_inset' " - for i in range(len(document.body)): - m = re.match(r'(.*)\\InsetSpace (.*)', document.body[i]) - if m: - before = m.group(1) - after = m.group(2) - subst = [before, "\\begin_inset Space " + after, "\\end_inset"] - document.body[i: i+1] = subst + " Convert '\\InsetSpace foo' to '\\begin_inset Space foo\n\\end_inset' " + i = 0 + while i < len(document.body): + m = re.match(r'(.*)\\InsetSpace (.*)', document.body[i]) + if m: + before = m.group(1) + after = m.group(2) + subst = [before, "\\begin_inset Space " + after, "\\end_inset"] + document.body[i: i+1] = subst + i = i + 3 + else: + i = i + 1 def revert_spaceinset(document): -- 2.39.2