diff --git a/services/web/frontend/js/features/source-editor/extensions/shortcuts.ts b/services/web/frontend/js/features/source-editor/extensions/shortcuts.ts index c718f5b925..01c3bb7de2 100644 --- a/services/web/frontend/js/features/source-editor/extensions/shortcuts.ts +++ b/services/web/frontend/js/features/source-editor/extensions/shortcuts.ts @@ -59,21 +59,35 @@ export const shortcuts = Prec.high( preventDefault: true, run: redo, }, + + // defaultKeymap maps Mod-/ to toggleLineComment, but + // w3c-keyname has a hard-coded mapping of Shift+key => character + // which uses a US keyboard layout, so we need to add more mappings. + + // Mod-/, but Spanish, Portuguese, German and Swedish keyboard layouts have / at Shift+7 + // (keyCode 55, mapped with Shift to &) { - key: 'Mod-Shift-/', + key: 'Mod-&', preventDefault: true, run: toggleLineComment, }, + // Mod-/, but German keyboard layouts have / at Cmd+Shift+ß + // Mod-/, but Czech keyboard layouts have / at Shift-ú + // (keyCode 191, mapped with Shift to ?) { - key: 'Mod-ß', + key: 'Mod-?', preventDefault: true, run: toggleLineComment, }, + // German keyboard layouts map 0xBF to #, + // so VS Code on Windows/Linux uses Ctrl-# to toggle line comments. + // This is an additional, undocumented shortcut for compatibility. { key: 'Ctrl-#', preventDefault: true, run: toggleLineComment, }, + { key: 'Ctrl-u', preventDefault: true, diff --git a/services/web/test/frontend/features/source-editor/components/codemirror-editor-shortcuts.spec.tsx b/services/web/test/frontend/features/source-editor/components/codemirror-editor-shortcuts.spec.tsx index e57a0e8572..3a46854119 100644 --- a/services/web/test/frontend/features/source-editor/components/codemirror-editor-shortcuts.spec.tsx +++ b/services/web/test/frontend/features/source-editor/components/codemirror-editor-shortcuts.spec.tsx @@ -36,15 +36,6 @@ describe('keyboard shortcuts', { scrollBehavior: false }, function () { window.metaAttributesCache = new Map() }) - it('comment line with {meta+shift+/}', function () { - cy.get('@line') - .type('text') - .type(`{${metaKey}+shift+/}`) - .should('have.text', '% text') - - cy.get('@line').type(`{${metaKey}+shift+/}`).should('have.text', 'text') - }) - it('comment line with {meta+/}', function () { cy.get('@line') .type('text') @@ -54,15 +45,6 @@ describe('keyboard shortcuts', { scrollBehavior: false }, function () { cy.get('@line').type(`{${metaKey}+/}`).should('have.text', 'text') }) - it('comment line with {meta+ß}', function () { - cy.get('@line') - .type('text') - .type(`{${metaKey}+ß}`) - .should('have.text', '% text') - - cy.get('@line').type(`{${metaKey}+ß}`).should('have.text', 'text') - }) - it('comment line with {ctrl+#}', function () { cy.get('@line').type('text') cy.get('@editor').trigger('keydown', { key: '#', ctrlKey: true })