macOS: treat C-/ specially again to prevent beep

Fixes #7310
pull/7320/head
Mitchell Hashimoto 2025-05-10 14:50:56 -07:00
parent ed1194cd75
commit c4f1c78fcf
No known key found for this signature in database
GPG Key ID: 523D5DC389D273BC
2 changed files with 10 additions and 11 deletions

View File

@ -1066,6 +1066,16 @@ extension Ghostty {
equivalent = "\r"
case "/":
// Treat C-/ as C-_. We do this because C-/ makes macOS make a beep
// sound and we don't like the beep sound.
if (!event.modifierFlags.contains(.control) ||
!event.modifierFlags.isDisjoint(with: [.shift, .command, .option])) {
return false
}
equivalent = "_"
default:
// It looks like some part of AppKit sometimes generates synthetic NSEvents
// with a zero timestamp. We never process these at this point. Concretely,

View File

@ -149,9 +149,6 @@ pub const Mods = packed struct(Mods.Backing) {
pub fn translation(self: Mods, option_as_alt: config.OptionAsAlt) Mods {
var result = self;
// Control is never used for translation.
result.ctrl = false;
// macos-option-as-alt for darwin
if (comptime builtin.target.os.tag.isDarwin()) alt: {
// Alt has to be set only on the correct side
@ -187,14 +184,6 @@ pub const Mods = packed struct(Mods.Backing) {
);
}
test "translation removes control" {
const testing = std.testing;
const mods: Mods = .{ .ctrl = true };
const result = mods.translation(.true);
try testing.expectEqual(Mods{}, result);
}
test "translation macos-option-as-alt" {
if (comptime !builtin.target.os.tag.isDarwin()) return error.SkipZigTest;