From b696d3f9607dd23788b885096ec84c32e4ed6b20 Mon Sep 17 00:00:00 2001 From: pagedown Date: Mon, 15 Nov 2021 17:05:45 +0800 Subject: [PATCH] Include all default shortcuts in the commented config --- kitty/conf/types.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/kitty/conf/types.py b/kitty/conf/types.py index 5435083f2..c0f4455d6 100644 --- a/kitty/conf/types.py +++ b/kitty/conf/types.py @@ -286,14 +286,14 @@ class Mapping: def key_text(self) -> str: return '' - def as_conf(self, commented: bool = False, level: int = 0) -> List[str]: + def as_conf(self, commented: bool = False, level: int = 0, action_group: List['Mapping'] = []) -> List[str]: ans: List[str] = [] - if self.documented: - a = ans.append - if self.add_to_default: - a(self.setting_name + ' ' + self.parseable_text) - if self.long_text: - a(''), a(render_block(self.long_text.strip())), a('') + a = ans.append + for sc in [self] + action_group: + if sc.documented and sc.add_to_default: + a(sc.setting_name + ' ' + sc.parseable_text) + if self.documented and self.long_text: + a(''), a(render_block(self.long_text.strip())), a('') return ans def as_rst( @@ -474,6 +474,8 @@ class Group: for item in self.iter_with_coalesced_options(): if isinstance(item, Option): lines = item.as_conf(option_group=self.coalesced_iterator_data.option_group_for_option(item)) + elif isinstance(item, Mapping): + lines = item.as_conf(commented, level + 1, action_group=self.coalesced_iterator_data.action_group_for_action(item)) else: lines = item.as_conf(commented, level + 1) ans.extend(lines)