Skip to content

Commit caaba84

Browse files
committed
Fix special ansi sequences not ignored and producing wrong colors
1 parent b71bec9 commit caaba84

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

colorama/ansitowin32.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,13 +222,26 @@ def extract_params(self, command, paramstring):
222222

223223
def call_win32(self, command, params):
224224
if command == 'm':
225+
# Ansi sequences started by specific param may need to be ignored, see #217
226+
skip = False
225227
for param in params:
228+
if skip:
229+
if skip is not True:
230+
skip -= 1
231+
continue
232+
if param in (2, 5):
233+
skip = 1 if param == 5 else 3
234+
continue
235+
skip = False
226236
if param in self.win32_calls:
227237
func_args = self.win32_calls[param]
228238
func = func_args[0]
229239
args = func_args[1:]
230240
kwargs = dict(on_stderr=self.on_stderr)
231241
func(*args, **kwargs)
242+
elif param in (38, 48):
243+
skip = True
244+
232245
elif command in 'J':
233246
winterm.erase_screen(params[0], on_stderr=self.on_stderr)
234247
elif command in 'K':

0 commit comments

Comments
 (0)