Skip to content

Commit 6155b0e

Browse files
fix: copy/delete shortcuts must bind extracted functions (#176)
Otherwise delete and copy shortcuts error when accessing fields on `this`.
1 parent 05f024d commit 6155b0e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/navigation_controller.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -651,8 +651,8 @@ export class NavigationController {
651651
/** Copy the block the cursor is currently on. */
652652
copy: {
653653
name: Constants.SHORTCUT_NAMES.COPY,
654-
preconditionFn: this.blockCopyPreconditionFn,
655-
callback: this.blockCopyCallbackFn,
654+
preconditionFn: this.blockCopyPreconditionFn.bind(this),
655+
callback: this.blockCopyCallbackFn.bind(this),
656656
keyCodes: [
657657
createSerializedKey(KeyCodes.C, [KeyCodes.CTRL]),
658658
createSerializedKey(KeyCodes.C, [KeyCodes.ALT]),
@@ -725,8 +725,8 @@ export class NavigationController {
725725
/** Keyboard shortcut to delete the block the cursor is currently on. */
726726
delete: {
727727
name: Constants.SHORTCUT_NAMES.DELETE,
728-
preconditionFn: this.deletePreconditionFn,
729-
callback: this.deleteCallbackFn,
728+
preconditionFn: this.deletePreconditionFn.bind(this),
729+
callback: this.deleteCallbackFn.bind(this),
730730
keyCodes: [KeyCodes.DELETE, KeyCodes.BACKSPACE],
731731
allowCollision: true,
732732
},

0 commit comments

Comments
 (0)