mirror of
https://github.com/Sei-Lisa/LSL-PyOptimizer
synced 2025-07-01 23:58:20 +00:00
Format LIST nodes; don't add indent to CONST list in calc mode
LIST nodes will be pretty-printed with newlines between elements if they have 5 elements or more. List constants won't be indented when in calc mode.
This commit is contained in:
parent
9a820a62d0
commit
906e76ea47
1 changed files with 16 additions and 4 deletions
|
@ -161,7 +161,7 @@ class outscript(object):
|
|||
return ret
|
||||
ret = '' if lslcommon.IsCalc else '\n'
|
||||
first = True
|
||||
self.indentlevel += 1
|
||||
self.indentlevel += 0 if lslcommon.IsCalc else 1
|
||||
for entry in value:
|
||||
ret += self.dent() + ('[ ' if first else ', ')
|
||||
save_listmode = self.listmode
|
||||
|
@ -169,8 +169,9 @@ class outscript(object):
|
|||
ret += self.Value2LSL(entry) + '\n'
|
||||
self.listmode = save_listmode
|
||||
first = False
|
||||
self.indentlevel -= 1
|
||||
return ret + self.dent() + self.indent + ']'
|
||||
ret += self.dent()
|
||||
self.indentlevel -= 0 if lslcommon.IsCalc else 1
|
||||
return ret + ']'
|
||||
|
||||
assert False, u'Value of unknown type in Value2LSL: ' + repr(value)
|
||||
|
||||
|
@ -291,7 +292,18 @@ class outscript(object):
|
|||
|
||||
if nt == 'LIST':
|
||||
self.listmode = True
|
||||
if len(child) < 5:
|
||||
ret = '[' + self.OutExprList(child) + ']'
|
||||
else:
|
||||
self.indentlevel += 0 if lslcommon.IsCalc else 1
|
||||
ret = '' if lslcommon.IsCalc else '\n'
|
||||
first = True
|
||||
for elem in child:
|
||||
ret += self.dent() + ('[ ' if first else ', ')
|
||||
ret += self.OutExpr(elem) + '\n'
|
||||
first = False
|
||||
ret += self.dent() + ']'
|
||||
self.indentlevel -= 0 if lslcommon.IsCalc else 1
|
||||
self.listmode = False
|
||||
return ret
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue