@@ -729,5 +729,87 @@ describe('KittyKeyboard', () => {
729729 assert . strictEqual ( result . key , '\x1b[57440u' ) ;
730730 } ) ;
731731 } ) ;
732+
733+ // https://github.com/microsoft/vscode/issues/304765
734+ describe ( 'macOS Option as Alt (macOptionIsMeta)' , ( ) => {
735+ const flags = KittyKeyboardFlags . DISAMBIGUATE_ESCAPE_CODES ;
736+ const press = KittyKeyboardEventType . PRESS ;
737+
738+ it ( 'Opt+f (key=ƒ) → CSI 102;3 u' , ( ) => {
739+ const result = kitty . evaluate ( createEvent ( { key : 'ƒ' , code : 'KeyF' , altKey : true } ) , flags , press , true ) ;
740+ assert . strictEqual ( result . key , '\x1b[102;3u' ) ;
741+ } ) ;
742+
743+ it ( 'Opt+b (key=∫) → CSI 98;3 u' , ( ) => {
744+ const result = kitty . evaluate ( createEvent ( { key : '∫' , code : 'KeyB' , altKey : true } ) , flags , press , true ) ;
745+ assert . strictEqual ( result . key , '\x1b[98;3u' ) ;
746+ } ) ;
747+
748+ it ( 'Opt+d (key=∂) → CSI 100;3 u' , ( ) => {
749+ const result = kitty . evaluate ( createEvent ( { key : '∂' , code : 'KeyD' , altKey : true } ) , flags , press , true ) ;
750+ assert . strictEqual ( result . key , '\x1b[100;3u' ) ;
751+ } ) ;
752+
753+ it ( 'Opt+n dead key (key=Dead, code=KeyN) → CSI 110;3 u' , ( ) => {
754+ const result = kitty . evaluate ( createEvent ( { key : 'Dead' , code : 'KeyN' , altKey : true } ) , flags , press , true ) ;
755+ assert . strictEqual ( result . key , '\x1b[110;3u' ) ;
756+ } ) ;
757+
758+ it ( 'Opt+e dead key (key=Dead, code=KeyE) → CSI 101;3 u' , ( ) => {
759+ const result = kitty . evaluate ( createEvent ( { key : 'Dead' , code : 'KeyE' , altKey : true } ) , flags , press , true ) ;
760+ assert . strictEqual ( result . key , '\x1b[101;3u' ) ;
761+ } ) ;
762+
763+ it ( 'Opt+u dead key (key=Dead, code=KeyU) → CSI 117;3 u' , ( ) => {
764+ const result = kitty . evaluate ( createEvent ( { key : 'Dead' , code : 'KeyU' , altKey : true } ) , flags , press , true ) ;
765+ assert . strictEqual ( result . key , '\x1b[117;3u' ) ;
766+ } ) ;
767+
768+ it ( 'Opt+5 (key=∞) → CSI 53;3 u' , ( ) => {
769+ const result = kitty . evaluate ( createEvent ( { key : '∞' , code : 'Digit5' , altKey : true } ) , flags , press , true ) ;
770+ assert . strictEqual ( result . key , '\x1b[53;3u' ) ;
771+ } ) ;
772+
773+ it ( 'Opt+Shift+f (key=Ï) → CSI 102;4 u' , ( ) => {
774+ const result = kitty . evaluate ( createEvent ( { key : 'Ï' , code : 'KeyF' , altKey : true , shiftKey : true } ) , flags , press , true ) ;
775+ assert . strictEqual ( result . key , '\x1b[102;4u' ) ;
776+ } ) ;
777+
778+ it ( 'Ctrl+Opt+f (key=ƒ) → CSI 102;7 u' , ( ) => {
779+ const result = kitty . evaluate ( createEvent ( { key : 'ƒ' , code : 'KeyF' , altKey : true , ctrlKey : true } ) , flags , press , true ) ;
780+ assert . strictEqual ( result . key , '\x1b[102;7u' ) ;
781+ } ) ;
782+
783+ it ( 'does not unwind when macOptionAsAlt is false (Linux Alt is a chord)' , ( ) => {
784+ const result = kitty . evaluate ( createEvent ( { key : 'a' , code : 'KeyA' , altKey : true } ) , flags , press , false ) ;
785+ assert . strictEqual ( result . key , '\x1b[97;3u' ) ;
786+ } ) ;
787+
788+ it ( 'does not unwind on Linux AZERTY (key=a, code=KeyQ) — uses ev.key not ev.code' , ( ) => {
789+ const result = kitty . evaluate ( createEvent ( { key : 'a' , code : 'KeyQ' , altKey : true } ) , flags , press , false ) ;
790+ assert . strictEqual ( result . key , '\x1b[97;3u' ) ;
791+ } ) ;
792+
793+ it ( 'does not unwind when macOptionAsAlt is false even with composed key' , ( ) => {
794+ const result = kitty . evaluate ( createEvent ( { key : 'ƒ' , code : 'KeyF' , altKey : true } ) , flags , press , false ) ;
795+ assert . strictEqual ( result . key , '\x1b[402;3u' ) ;
796+ } ) ;
797+
798+ it ( 'does not unwind when altKey is false' , ( ) => {
799+ const result = kitty . evaluate ( createEvent ( { key : 'ƒ' , code : 'KeyF' } ) , flags , press , true ) ;
800+ assert . strictEqual ( result . key , 'ƒ' ) ;
801+ } ) ;
802+
803+ it ( 'falls through when ev.code is not Key*/Digit* (Opt+;)' , ( ) => {
804+ const result = kitty . evaluate ( createEvent ( { key : '…' , code : 'Semicolon' , altKey : true } ) , flags , press , true ) ;
805+ assert . strictEqual ( result . key , '\x1b[8230;3u' ) ;
806+ } ) ;
807+
808+ it ( 'Opt+f release with REPORT_EVENT_TYPES → CSI 102;3:3 u' , ( ) => {
809+ const releaseFlags = KittyKeyboardFlags . DISAMBIGUATE_ESCAPE_CODES | KittyKeyboardFlags . REPORT_EVENT_TYPES ;
810+ const result = kitty . evaluate ( createEvent ( { key : 'ƒ' , code : 'KeyF' , altKey : true } ) , releaseFlags , KittyKeyboardEventType . RELEASE , true ) ;
811+ assert . strictEqual ( result . key , '\x1b[102;3:3u' ) ;
812+ } ) ;
813+ } ) ;
732814 } ) ;
733815} ) ;
0 commit comments