From c08d1edb5d8af8b8fdc12acae4cf5facff68c0bc Mon Sep 17 00:00:00 2001 From: Sei Lisa Date: Fri, 13 Jan 2017 00:25:35 +0100 Subject: [PATCH] Fix nested lists disabling list mode. Lists can't contain lists at runtime, but they can at parse time, so the optimizer must behave properly when handling nested lists. And it didn't, because it neglected to preserve the previous state of self.listmode. So we fix that. --- lslopt/lsloutput.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lslopt/lsloutput.py b/lslopt/lsloutput.py index 12f02d0..80d9841 100644 --- a/lslopt/lsloutput.py +++ b/lslopt/lsloutput.py @@ -150,21 +150,23 @@ class outscript(object): if value == []: return '[]' if len(value) < 5: + save_listmode = self.listmode self.listmode = True ret = '[' + self.Value2LSL(value[0]) for elem in value[1:]: ret += ', ' + self.Value2LSL(elem) ret += ']' - self.listmode = False + self.listmode = save_listmode return ret ret = '' if lslcommon.IsCalc else '\n' first = True self.indentlevel += 1 for entry in value: ret += self.dent() + ('[ ' if first else ', ') + save_listmode = self.listmode self.listmode = True ret += self.Value2LSL(entry) + '\n' - self.listmode = False + self.listmode = save_listmode first = False self.indentlevel -= 1 return ret + self.dent() + self.indent + ']'