Skip to content

Commit

Permalink
macOS: Fix shortcuts that become entries in the global menubar being …
Browse files Browse the repository at this point in the history
…reported as removed shortcuts in the debug output
  • Loading branch information
kovidgoyal committed Sep 8, 2024
1 parent f9504b4 commit 3b8c7f6
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
2 changes: 2 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ Detailed list of changes

- Fix a regression in the previous release that broke use of the ``cd`` command in session files (:iss:`7829`)

- macOS: Fix shortcuts that become entries in the global menubar being reported as removed shortcuts in the debug output

0.36.2 [2024-09-06]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
2 changes: 1 addition & 1 deletion kitty/boss.py
Original file line number Diff line number Diff line change
Expand Up @@ -3034,7 +3034,7 @@ def debug_config(self) -> None:
from .debug_config import debug_config
w = self.window_for_dispatch or self.active_window
if w is not None:
output = debug_config(get_options())
output = debug_config(get_options(), self.mappings.global_shortcuts)
set_clipboard_string(re.sub(r'\x1b.+?m', '', output))
output += '\n\x1b[35mThis debug output has been copied to the clipboard\x1b[m'
self.display_scrollback(w, output, title=_('Current kitty options'), report_cursor=False)
Expand Down
11 changes: 8 additions & 3 deletions kitty/debug_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def compare_maps(



def compare_opts(opts: KittyOpts, print: Print) -> None:
def compare_opts(opts: KittyOpts, global_shortcuts: dict[str, SingleKey] | None, print: Print) -> None:
from .config import load_config
print()
print('Config options different from defaults:')
Expand Down Expand Up @@ -134,6 +134,11 @@ def as_str(defns: Sequence[KeyDefinition]) -> str:
initial = {as_sc(k, v[0]): as_str(v) for k, v in initial_.keymap.items()}
final_ = opts.keyboard_modes.get(kmn, KeyboardMode(kmn))
final = {as_sc(k, v[0]): as_str(v) for k, v in final_.keymap.items()}
if not kmn and global_shortcuts:
for action, sk in global_shortcuts.items():
sc = Shortcut((sk,))
if sc not in final:
final[sc] = action
compare_maps(final, opts.kitty_mod, initial, default_opts.kitty_mod, print, mode_name=kmn)
new_keyboard_modes = set(opts.keyboard_modes) - set(default_opts.keyboard_modes)
for kmn in new_keyboard_modes:
Expand Down Expand Up @@ -229,7 +234,7 @@ def compositor_name() -> str:
return ans


def debug_config(opts: KittyOpts) -> str:
def debug_config(opts: KittyOpts, global_shortcuts: dict[str, SingleKey] | None = None) -> str:
from io import StringIO
out = StringIO()
p = partial(print, file=out)
Expand Down Expand Up @@ -276,7 +281,7 @@ def debug_config(opts: KittyOpts) -> str:
if opts.config_overrides:
p(green('Loaded config overrides:'))
p(' ', '\n '.join(opts.config_overrides))
compare_opts(opts, p)
compare_opts(opts, global_shortcuts, p)
p()
p(green('Important environment variables seen by the kitty process:'))

Expand Down
2 changes: 1 addition & 1 deletion kitty/keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def __init__(self, global_shortcuts:Optional[dict[str, SingleKey]] = None, callb
def current_keyboard_mode_name(self) -> str:
return self.keyboard_mode_stack[-1].name if self.keyboard_mode_stack else ''

def update_keymap(self, global_shortcuts:Optional[dict[str, SingleKey]] = None) -> None:
def update_keymap(self, global_shortcuts: Optional[dict[str, SingleKey]] = None) -> None:
if global_shortcuts is None:
global_shortcuts = self.set_cocoa_global_shortcuts(self.get_options()) if is_macos else {}
self.global_shortcuts_map: KeyMap = {v: [KeyDefinition(definition=k)] for k, v in global_shortcuts.items()}
Expand Down

0 comments on commit 3b8c7f6

Please sign in to comment.