]> git.lyx.org Git - lyx.git/commitdiff
Fix convert_spaceinset again.
authorRichard Heck <rgheck@comcast.net>
Sun, 1 Jun 2008 14:22:11 +0000 (14:22 +0000)
committerRichard Heck <rgheck@comcast.net>
Sun, 1 Jun 2008 14:22:11 +0000 (14:22 +0000)
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

index 83e082f54c176c5fca0a715dd687b2552ed83dee..b3bad13386fad49c1849f6c2cf1027f4567f4534 100644 (file)
@@ -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):