From b21f5ec1049357e2fd439bf0106bc7bd8f9be7d6 Mon Sep 17 00:00:00 2001 From: udf Date: Sun, 19 May 2019 22:59:12 +0200 Subject: [PATCH 1/2] Fix trailing whitespaces kate you're better than this --- stdplugins/info.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/stdplugins/info.py b/stdplugins/info.py index a22fc5a..d078e82 100644 --- a/stdplugins/info.py +++ b/stdplugins/info.py @@ -45,11 +45,13 @@ def yaml_format(obj, indent=0): if not formatted.strip(): continue result.append(' ' * (indent if has_multiple_items else 1)) - result.append(f'{k}: {formatted}') + result.append(f'{k}:') + if not formatted[0].isspace(): + result.append(' ') + result.append(f'{formatted}') result.append('\n') result.pop() indent -= 2 - result.append(' ' * indent) elif isinstance(obj, str): # truncate long strings and display elipsis result = repr(obj[:STR_LEN_MAX]) @@ -75,7 +77,6 @@ def yaml_format(obj, indent=0): result.append('\n') result.pop() indent -= 2 - result.append(' ' * indent) else: return repr(obj) From 573f36bf57e3d95d3e36e6050fba5ff7c989f112 Mon Sep 17 00:00:00 2001 From: udf Date: Sun, 19 May 2019 23:00:23 +0200 Subject: [PATCH 2/2] fix broken indentation when lots of nested items are present --- stdplugins/info.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/stdplugins/info.py b/stdplugins/info.py index d078e82..9129ce2 100644 --- a/stdplugins/info.py +++ b/stdplugins/info.py @@ -37,7 +37,7 @@ def yaml_format(obj, indent=0): has_multiple_items = len(items) > 2 if has_multiple_items: result.append('\n') - indent += 2 + indent += 2 for k, v in items: if k == '_' or v is None: continue @@ -51,7 +51,8 @@ def yaml_format(obj, indent=0): result.append(f'{formatted}') result.append('\n') result.pop() - indent -= 2 + if has_multiple_items: + indent -= 2 elif isinstance(obj, str): # truncate long strings and display elipsis result = repr(obj[:STR_LEN_MAX])