Browse Source

Use Ctrl+Shift+C for the add-comment shortcut while keeping Cmd+Shift+C active (#32624)

GitOrigin-RevId: 5fdf9ae7dd0fa194c3ac6acf9abb70ac9721fd2e
Copilot 1 month ago
parent
commit
ea1871b0df

+ 6 - 1
services/web/frontend/js/features/source-editor/extensions/shortcuts.ts

@@ -119,7 +119,12 @@ export const shortcuts = Prec.high(
       run: toggleReviewPanel,
       run: toggleReviewPanel,
     },
     },
     {
     {
-      key: 'Mod-Shift-c',
+      key: 'Ctrl-Shift-c',
+      preventDefault: true,
+      run: addNewCommentFromKbdShortcut,
+    },
+    {
+      key: 'Cmd-Shift-c',
       preventDefault: true,
       preventDefault: true,
       run: addNewCommentFromKbdShortcut,
       run: addNewCommentFromKbdShortcut,
     },
     },

+ 14 - 0
services/web/test/frontend/features/source-editor/components/codemirror-editor-shortcuts.spec.tsx

@@ -75,6 +75,20 @@ describe('keyboard shortcuts', { scrollBehavior: false }, function () {
     })
     })
   })
   })
 
 
+  it('dispatches add comment with {ctrl+shift+c}', function () {
+    cy.window().then(win => {
+      win.addEventListener('add-new-review-comment', cy.stub().as('addComment'))
+    })
+
+    cy.get('@editor').trigger('keydown', {
+      key: 'c',
+      ctrlKey: true,
+      shiftKey: true,
+    })
+
+    cy.get('@addComment').should('have.been.calledOnce')
+  })
+
   it('indent line with {tab}', function () {
   it('indent line with {tab}', function () {
     cy.get('@line').trigger('keydown', { key: 'Tab' })
     cy.get('@line').trigger('keydown', { key: 'Tab' })
     cy.get('@line').should('have.text', '    ')
     cy.get('@line').should('have.text', '    ')