Calculate the line length properly, include the provided extra indentation
authorJohan Dahlin <johan@gnome.org>
Mon, 28 Apr 2008 22:37:23 +0000 (22:37 +0000)
committerJohan Dahlin <johan@src.gnome.org>
Mon, 28 Apr 2008 22:37:23 +0000 (22:37 +0000)
2008-04-28  Johan Dahlin  <johan@gnome.org>

    * giscanner/xmlwriter.py: Calculate the line length properly,
    include the provided extra indentation in the calculation, really.

svn path=/trunk/; revision=256

ChangeLog
giscanner/xmlwriter.py

index b379166caba33903787712301bdc3b186f9d0a35..b5d82c49746679b34a4679f0a8d143c35e9eab2b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2008-04-28  Johan Dahlin  <johan@gnome.org>
+
+       * giscanner/xmlwriter.py: Calculate the line length properly,
+       include the provided extra indentation in the calculation, really.
+
 2008-04-28  Johan Dahlin  <jdahlin@async.com.br>
 
        * giscanner/ast.py:
index 2063106198bab1815de945a587ac53e70f713688..4dee3e2fcf0f310b18fbcfa26cdd68406f516fc7 100644 (file)
@@ -38,15 +38,15 @@ class XMLWriter(object):
             return -1
         attr_length = 0
         for attr, value in attributes:
-            attr_length += 1 + len(attr) + len(quoteattr(value))
+            attr_length += 2 + len(attr) + len(quoteattr(value))
         return attr_length + indent
 
-    def _collect_attributes(self, attributes, indent=-1):
+    def _collect_attributes(self, attributes, extra_indent=-1):
         if not attributes:
             return ''
-
-        if self._calc_attrs_length(attributes, indent) > 79:
-            indent_len = self._indent + indent
+        extra_indent += len(self._indent_char) * self._indent
+        if self._calc_attrs_length(attributes, extra_indent) > 79:
+            indent_len = extra_indent
         else:
             indent_len = 0
         first = True
@@ -62,7 +62,7 @@ class XMLWriter(object):
 
     def _open_tag(self, tag_name, attributes=None):
         attrs = self._collect_attributes(
-            attributes, len(tag_name) + 1)
+            attributes, len(tag_name) + 2)
         self.write_line('<%s%s>' % (tag_name, attrs))
 
     def _close_tag(self, tag_name):