From 76f84e32c408445e6f8c080d00014409a12185c7 Mon Sep 17 00:00:00 2001 From: pagedown Date: Sat, 30 Apr 2022 02:23:33 +0800 Subject: [PATCH] Fix the generated sample kitty.conf containing invalid options --- kitty/conf/types.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/kitty/conf/types.py b/kitty/conf/types.py index beebe555d..54a5faf46 100644 --- a/kitty/conf/types.py +++ b/kitty/conf/types.py @@ -289,7 +289,11 @@ class MultiOption: for k in self.items: if k.documented: documented = True - a(f'{self.name} {k.defval_as_str if k.add_to_default else ""}'.rstrip()) + if k.add_to_default: + a(f'{self.name} {k.defval_as_str}'.rstrip()) + else: + # Comment out multi-options that have no default values + a(f'# {self.name}'.rstrip()) if not k.add_to_default and k.defval_as_str: a('') a(f'#: E.g. {self.name} {k.defval_as_str}'.rstrip()) @@ -565,6 +569,9 @@ class Group: if commented: ans = [x if x.startswith('#') or not x.strip() else (f'# {x}') for x in ans] + else: + # Comment out any invalid options that have no value + ans = [f'# {x}' if not x.startswith('#') and len(x.strip().split()) == 1 else x for x in ans] return ans