mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
[cm6] Improve keyboard shortcuts for toggling line comments (#13067)
GitOrigin-RevId: dd08778ea3621eefa75f306b2dada3f2c484f76c
This commit is contained in:
parent
c8c17bca38
commit
c8a72e96d4
2 changed files with 16 additions and 20 deletions
|
@ -59,21 +59,35 @@ export const shortcuts = Prec.high(
|
||||||
preventDefault: true,
|
preventDefault: true,
|
||||||
run: redo,
|
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,
|
preventDefault: true,
|
||||||
run: toggleLineComment,
|
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,
|
preventDefault: true,
|
||||||
run: toggleLineComment,
|
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-#',
|
key: 'Ctrl-#',
|
||||||
preventDefault: true,
|
preventDefault: true,
|
||||||
run: toggleLineComment,
|
run: toggleLineComment,
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
key: 'Ctrl-u',
|
key: 'Ctrl-u',
|
||||||
preventDefault: true,
|
preventDefault: true,
|
||||||
|
|
|
@ -36,15 +36,6 @@ describe('keyboard shortcuts', { scrollBehavior: false }, function () {
|
||||||
window.metaAttributesCache = new Map()
|
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 () {
|
it('comment line with {meta+/}', function () {
|
||||||
cy.get('@line')
|
cy.get('@line')
|
||||||
.type('text')
|
.type('text')
|
||||||
|
@ -54,15 +45,6 @@ describe('keyboard shortcuts', { scrollBehavior: false }, function () {
|
||||||
cy.get('@line').type(`{${metaKey}+/}`).should('have.text', 'text')
|
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 () {
|
it('comment line with {ctrl+#}', function () {
|
||||||
cy.get('@line').type('text')
|
cy.get('@line').type('text')
|
||||||
cy.get('@editor').trigger('keydown', { key: '#', ctrlKey: true })
|
cy.get('@editor').trigger('keydown', { key: '#', ctrlKey: true })
|
||||||
|
|
Loading…
Reference in a new issue