#766: Fix Ctrl-Backspace and Ctrl-Del
diff --git a/src/services/keystroke.js b/src/services/keystroke.js
index fc3fc8e..a53cb5a 100644
--- a/src/services/keystroke.js
+++ b/src/services/keystroke.js
@@ -241,11 +241,15 @@
_.ctrlDeleteDir = function(dir) {
prayDirection(dir);
var cursor = this.cursor;
- if (!cursor[L] || cursor.selection) return this.deleteDir();
+ if (!cursor[dir] || cursor.selection) return this.deleteDir(dir);
this.notify('edit');
- Fragment(cursor.parent.ends[L], cursor[L]).remove();
- cursor.insAtDirEnd(L, cursor.parent);
+ if (dir === L) {
+ Fragment(cursor.parent.ends[L], cursor[L]).remove();
+ } else {
+ Fragment(cursor[R], cursor.parent.ends[R]).remove();
+ };
+ cursor.insAtDirEnd(dir, cursor.parent);
if (cursor[L].siblingDeleted) cursor[L].siblingDeleted(cursor.options, R);
if (cursor[R].siblingDeleted) cursor[R].siblingDeleted(cursor.options, L);
diff --git a/test/unit/typing.test.js b/test/unit/typing.test.js
index c2f8462..b67677e 100644
--- a/test/unit/typing.test.js
+++ b/test/unit/typing.test.js
@@ -472,6 +472,26 @@
assertLatex('\\left(1+2\\right)+3+4+5');
});
+ test('typing Ctrl-Backspace deletes everything to the left of the cursor', function () {
+ mq.typedText('12345');
+ assertLatex('12345');
+ mq.keystroke('Left Left');
+ mq.keystroke('Ctrl-Backspace');
+ assertLatex('45');
+ mq.keystroke('Ctrl-Backspace');
+ assertLatex('45');
+ });
+
+ test('typing Ctrl-Del deletes everything to the right of the cursor', function () {
+ mq.typedText('12345');
+ assertLatex('12345');
+ mq.keystroke('Left Left');
+ mq.keystroke('Ctrl-Del');
+ assertLatex('123');
+ mq.keystroke('Ctrl-Del');
+ assertLatex('123');
+ });
+
suite('pipes', function() {
test('typing then backspacing a pipe in the middle of 1+2+3+4', function() {
mq.typedText('1+2+3+4');