From f0128c37c07544fadf3b5d02e7f9d4471db1a8fd Mon Sep 17 00:00:00 2001 From: Jonathan Curran Date: Tue, 11 Jun 2024 22:50:31 -0600 Subject: [PATCH] fix(editor): common macos shortcuts for next and previous respected Problem: On macOS, next and previous tab for documents/tabs within applications are bound to Cmd-Shift-[ and Cmd-Shift-]. Pressing these while in the editor changes tabs but invokes the delimiter insertion code. Solution: Only run the delimiter handling code if the `Cmd` button is not held pressed. This is detectable via use of the `meta` key in the browser. --- site/src/editor/mod.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/site/src/editor/mod.rs b/site/src/editor/mod.rs index 6a666f62e..d4a18ab87 100644 --- a/site/src/editor/mod.rs +++ b/site/src/editor/mod.rs @@ -286,7 +286,7 @@ pub fn Editor<'a>( } } OutputItem::Svg(s) => view!(
) .into_view(), @@ -688,7 +688,7 @@ pub fn Editor<'a>( }); } // Handle open delimiters - "(" | "[" | "{" => { + "(" | "[" | "{" if !event.meta_key() => { // Surround the selected text with delimiters let (open, close) = match key { "\"" => ('"', '"'), @@ -714,7 +714,7 @@ pub fn Editor<'a>( }); } // Handle close delimiters - ")" | "]" | "}" => { + ")" | "]" | "}" if !event.meta_key() => { let (start, end) = get_code_cursor().unwrap(); let code = get_code(); let close = key.chars().next().unwrap();