fix: improve reliability of disposing and reinitializing plugin #687
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #675
This ends up being a somewhat random collection of things but they were all needed to set up the tests + get them to pass.
Test setup / config related stuff:
.mocha.js.type: "module"topackage.json#611 without that PR doing additional work (which might need to happen in blockly-samples because the blockly-scripts test script is specifically looking for.mocha.jsfiles not.mocha.cjsfiles)npm run testor you can run them alone withnpm run test:mochasrc/fooinstead of../fooActual plugin code stuff:
commitMoveshortcut is registered when a move starts and unregistered when a move finishes. now also unregister it (conditionally) in case the workspace was possibly disposed during a moveinstallas it was never reset. rearranged the code so the array is only built once.displayTextfor the context menu items to use an arrow function instead of callinggetMenuItemdirectly, since the function would now be evaluated earlier. otherwise the code is unchanged.edit_or_confirmshortcut, and made its precondition return false if the workspace is dragging, since in that case thefinishMoveshortcut is what will happen for the Enter key. this makes the shortcuts more resilient to being installed in different orders since their preconditions now should never overlap.