From ef918790caa86b2871ae11f40803c48acf733caf Mon Sep 17 00:00:00 2001 From: Peter VandeHaar Date: Wed, 20 Oct 2021 16:30:40 -0400 Subject: [PATCH] Add keybinding meta-backspace to delete to beginning of line --- src/static/js/ace2_inner.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/static/js/ace2_inner.js b/src/static/js/ace2_inner.js index 785473df7..a8b98ac16 100644 --- a/src/static/js/ace2_inner.js +++ b/src/static/js/ace2_inner.js @@ -2433,7 +2433,11 @@ function Ace2Inner(editorInfo, cssManagers) { const lineEntry = rep.lines.atIndex(lineNum); const lineText = lineEntry.text; const lineMarker = lineEntry.lineMarker; - if (/^ +$/.exec(lineText.substring(lineMarker, col))) { + if (evt.metaKey && col > lineMarker) { + // cmd-backspace deletes to start of line (if not already at start) + performDocumentReplaceRange([lineNum, lineMarker], [lineNum, col], ''); + handled = true; + } else if (/^ +$/.exec(lineText.substring(lineMarker, col))) { const col2 = col - lineMarker; const tabSize = THE_TAB.length; const toDelete = ((col2 - 1) % tabSize) + 1;