@lvce-editor/quick-pick-worker 4.18.0 → 4.18.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4804,6 +4804,30 @@ const selectItem = async (state, label) => {
4804
4804
  return selectIndex(state, index);
4805
4805
  };
4806
4806
 
4807
+ const queues = new Map();
4808
+ const serialize = command => {
4809
+ return async (uid, ...args) => {
4810
+ const previous = queues.get(uid) || Promise.resolve();
4811
+ const run = async () => {
4812
+ try {
4813
+ await previous;
4814
+ } catch {
4815
+ // The previous caller receives its error; later commands must still run.
4816
+ }
4817
+ await command(uid, ...args);
4818
+ };
4819
+ const current = run();
4820
+ queues.set(uid, current);
4821
+ try {
4822
+ await current;
4823
+ } finally {
4824
+ if (queues.get(uid) === current) {
4825
+ queues.delete(uid);
4826
+ }
4827
+ }
4828
+ };
4829
+ };
4830
+
4807
4831
  const showQuickInput = async ({
4808
4832
  id,
4809
4833
  ignoreFocusOut,
@@ -4882,7 +4906,7 @@ const commandMap = {
4882
4906
  'QuickPick.handleBlur': wrapCommand(handleBlur),
4883
4907
  'QuickPick.handleClickAt': wrapCommand(handleClickAt),
4884
4908
  'QuickPick.handleFocus': wrapCommand(handleFocus),
4885
- 'QuickPick.handleInput': wrapAsyncCommand(handleInputWithContext),
4909
+ 'QuickPick.handleInput': serialize(wrapAsyncCommand(handleInputWithContext)),
4886
4910
  'QuickPick.handleMessagePort': handleMessagePort,
4887
4911
  'QuickPick.handleRendererProcessMessagePort': handleDirectMessagePort,
4888
4912
  'QuickPick.handleScrollBarPointerDown': wrapCommand(handleScrollBarPointerDown),
@@ -4893,7 +4917,7 @@ const commandMap = {
4893
4917
  'QuickPick.loadContent': wrapAsyncCommand(loadContentWithContext),
4894
4918
  'QuickPick.render2': render2,
4895
4919
  'QuickPick.renderEventListeners': renderEventListeners,
4896
- 'QuickPick.selectCurrentIndex': wrapCommand(selectCurrentIndex),
4920
+ 'QuickPick.selectCurrentIndex': serialize(wrapCommand(selectCurrentIndex)),
4897
4921
  'QuickPick.selectIndex': wrapCommand(selectIndex),
4898
4922
  'QuickPick.selectItem': wrapCommand(selectItem),
4899
4923
  'QuickPick.setDeltaY': wrapCommand(setDeltaY),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/quick-pick-worker",
3
- "version": "4.18.0",
3
+ "version": "4.18.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/lvce-editor/quick-pick-worker.git"