We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e703e0d commit 1c2678eCopy full SHA for 1c2678e
Lib/textwrap.py
@@ -434,17 +434,9 @@ def dedent(text):
434
lines = text.split("\n")
435
436
splitting = os.path.commonprefix(tuple(filter(lambda x: x.lstrip(), lines)))
437
+ margin_len = len(splitting) - len(splitting.lstrip())
438
- margin_len = 0
439
-
440
- for split in splitting:
441
- if ' \t' in split :
442
- margin_len += 1
443
- else:
444
- break
445
446
- # Apply margin removal (most common case) with minimal operations
447
- return "\n".join([line[margin_len:] if line.strip() else "\n" if line.endswith("\n") else "" for line in lines])
+ return "\n".join([line[margin_len:] if line.lstrip() else "\n" if line.endswith("\n") else "" for line in lines])
448
449
450
def indent(text, prefix, predicate=None):
0 commit comments