Script Editor: Add shortcut key Shift+Cmd+K/Shift+Ctrl+K to delete the current line (#3156)

This shortcut is quite well known from VS Code.
It is basically the same as Cmd+X / Ctrl X, but without putting the deleted stuff into the clipboard.

Signed-off-by: Jimmy Tanagra <jcode@tanagra.id.au>
pull/2967/head
jimtng 2025-04-20 22:48:40 +10:00 committed by GitHub
parent e3812d5105
commit 19c3a42d60
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 17 additions and 2 deletions

View File

@ -320,14 +320,29 @@ export default {
}
}
extraKeys['Shift-Tab'] = 'indentLess'
extraKeys['Cmd-/'] = 'toggleComment'
extraKeys['Ctrl-/'] = 'toggleComment'
extraKeys['Cmd-/'] = extraKeys['Ctrl-/'] = 'toggleComment'
extraKeys['Shift-Cmd-K'] = extraKeys['Shift-Ctrl-K'] = this.deleteCurrentLine
cm.setOption('extraKeys', extraKeys)
cm.addOverlay(indentGuidesOverlay)
cm.refresh()
},
onCmCodeChange (newCode) {
this.$emit('input', newCode)
},
deleteCurrentLine (cm) {
if (cm.somethingSelected()) {
cm.replaceSelection('')
} else {
const cursor = cm.getCursor()
if (cursor.line === cm.lastLine() && cursor.line !== cm.firstLine()) {
const prevLine = cursor.line - 1
cm.replaceRange('', { line: prevLine, ch: cm.getLine(prevLine).length }, { line: cursor.line, ch: cm.getLine(cursor.line).length })
cm.setCursor({ line: prevLine, ch: 0 })
} else {
cm.replaceRange('', { line: cursor.line, ch: 0 }, { line: cursor.line + 1, ch: 0 })
cm.setCursor({ line: cursor.line, ch: 0 })
}
}
}
},
computed: {