From 3d19133d70334eb9a46b4788f95e3c5ac44cc41d Mon Sep 17 00:00:00 2001 From: Ionite Date: Fri, 24 Feb 2023 15:04:58 -0500 Subject: Fix and simplify logic for optional line numbering --- bot/exts/utils/snekbox/_cog.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/bot/exts/utils/snekbox/_cog.py b/bot/exts/utils/snekbox/_cog.py index f4032e4a1..a549ec70a 100644 --- a/bot/exts/utils/snekbox/_cog.py +++ b/bot/exts/utils/snekbox/_cog.py @@ -262,15 +262,15 @@ class Snekbox(Cog): return "Code block escape attempt detected; will not output result", paste_link truncated = False - lines = output.count("\n") + lines = output.splitlines() - if lines > 0: + if lines: if line_nums: - output = [f"{i:03d} | {line}" for i, line in enumerate(output.split('\n'), 1)] - output = output[:max_lines+1] # Limiting to max+1 lines - output = "\n".join(output) + lines = [f"{i:03d} | {line}" for i, line in enumerate(lines, 1)] + lines = lines[:max_lines+1] # Limiting to max+1 lines + output = "\n".join(lines) - if lines > max_lines: + if len(lines) > max_lines: truncated = True if len(output) >= max_chars: output = f"{output[:max_chars]}\n... (truncated - too long, too many lines)" -- cgit v1.2.3