Skip to content

Commit

Permalink
fix: copy/delete shortcuts must bind extracted functions (#176)
Browse files Browse the repository at this point in the history
Otherwise delete and copy shortcuts error when accessing fields on `this`.
  • Loading branch information
microbit-matt-hillsdon authored Jan 28, 2025
1 parent 05f024d commit 6155b0e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/navigation_controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -651,8 +651,8 @@ export class NavigationController {
/** Copy the block the cursor is currently on. */
copy: {
name: Constants.SHORTCUT_NAMES.COPY,
preconditionFn: this.blockCopyPreconditionFn,
callback: this.blockCopyCallbackFn,
preconditionFn: this.blockCopyPreconditionFn.bind(this),
callback: this.blockCopyCallbackFn.bind(this),
keyCodes: [
createSerializedKey(KeyCodes.C, [KeyCodes.CTRL]),
createSerializedKey(KeyCodes.C, [KeyCodes.ALT]),
Expand Down Expand Up @@ -725,8 +725,8 @@ export class NavigationController {
/** Keyboard shortcut to delete the block the cursor is currently on. */
delete: {
name: Constants.SHORTCUT_NAMES.DELETE,
preconditionFn: this.deletePreconditionFn,
callback: this.deleteCallbackFn,
preconditionFn: this.deletePreconditionFn.bind(this),
callback: this.deleteCallbackFn.bind(this),
keyCodes: [KeyCodes.DELETE, KeyCodes.BACKSPACE],
allowCollision: true,
},
Expand Down

0 comments on commit 6155b0e

Please sign in to comment.