Fix reloading of config not working when kitty.conf does not exist when kitty is launched

Fixes #5071
This commit is contained in:
Kovid Goyal
2022-05-08 20:57:23 +05:30
parent 2427d2d9da
commit 600c595fdf
3 changed files with 11 additions and 3 deletions

View File

@@ -57,6 +57,8 @@ Detailed list of changes
- macOS: Add the :opt:`macos_colorspace` option to control what color space colors are rendered in (:iss:`4686`) - macOS: Add the :opt:`macos_colorspace` option to control what color space colors are rendered in (:iss:`4686`)
- Fix reloading of config not working when :file:`kitty.conf` does not exist when kitty is launched (:iss:`5071`)
0.25.0 [2022-04-11] 0.25.0 [2022-04-11]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@@ -1964,8 +1964,10 @@ class Boss:
''') ''')
def load_config_file(self, *paths: str, apply_overrides: bool = True) -> None: def load_config_file(self, *paths: str, apply_overrides: bool = True) -> None:
from .config import load_config from .config import load_config
from .cli import default_config_paths
old_opts = get_options() old_opts = get_options()
paths = paths or old_opts.config_paths prev_paths = old_opts.config_paths or default_config_paths(self.args.config)
paths = paths or prev_paths
bad_lines: List[BadLine] = [] bad_lines: List[BadLine] = []
opts = load_config(*paths, overrides=old_opts.config_overrides if apply_overrides else None, accumulate_bad_lines=bad_lines) opts = load_config(*paths, overrides=old_opts.config_overrides if apply_overrides else None, accumulate_bad_lines=bad_lines)
if bad_lines: if bad_lines:

View File

@@ -787,9 +787,13 @@ def parse_args(
SYSTEM_CONF = f'/etc/xdg/{appname}/{appname}.conf' SYSTEM_CONF = f'/etc/xdg/{appname}/{appname}.conf'
def default_config_paths(conf_paths: Sequence[str]) -> Tuple[str, ...]:
return tuple(resolve_config(SYSTEM_CONF, defconf, conf_paths))
def create_opts(args: CLIOptions, accumulate_bad_lines: Optional[List[BadLineType]] = None) -> KittyOpts: def create_opts(args: CLIOptions, accumulate_bad_lines: Optional[List[BadLineType]] = None) -> KittyOpts:
from .config import load_config from .config import load_config
config = tuple(resolve_config(SYSTEM_CONF, defconf, args.config)) config = default_config_paths(args.config)
# Does not cover the case where `name =` when `=` is the value. # Does not cover the case where `name =` when `=` is the value.
pat = re.compile(r'^([a-zA-Z0-9_]+)[ \t]*=') pat = re.compile(r'^([a-zA-Z0-9_]+)[ \t]*=')
overrides = (pat.sub(r'\1 ', a.lstrip()) for a in args.override or ()) overrides = (pat.sub(r'\1 ', a.lstrip()) for a in args.override or ())
@@ -799,6 +803,6 @@ def create_opts(args: CLIOptions, accumulate_bad_lines: Optional[List[BadLineTyp
def create_default_opts() -> KittyOpts: def create_default_opts() -> KittyOpts:
from .config import load_config from .config import load_config
config = tuple(resolve_config(SYSTEM_CONF, defconf, ())) config = default_config_paths(())
opts = load_config(*config) opts = load_config(*config)
return opts return opts