@lvce-editor/quick-pick-worker 4.17.2 → 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.
@@ -1313,6 +1313,8 @@ const Symbol$3 = 8;
1313
1313
  const View$3 = 9;
1314
1314
  const WorkspaceSymbol$2 = 10;
1315
1315
  const LanguageMode$1 = 11;
1316
+ const EndOfLine$1 = 12;
1317
+ const Indentation$1 = 13;
1316
1318
  const EveryThing$1 = 100;
1317
1319
 
1318
1320
  const getCancelResult$1 = args => {
@@ -2433,7 +2435,7 @@ const toProtoVisibleItem$4 = name => {
2433
2435
  };
2434
2436
  return pick;
2435
2437
  };
2436
- const getPicks$d = async (searchValue, args, {
2438
+ const getPicks$f = async (searchValue, args, {
2437
2439
  assetDir = '',
2438
2440
  platform = 0
2439
2441
  } = {}) => {
@@ -2569,7 +2571,7 @@ const toProtoVisibleItem$3 = item => {
2569
2571
  // @ts-ignore
2570
2572
  return pick;
2571
2573
  };
2572
- const getPicks$c = async (value, args, {
2574
+ const getPicks$e = async (value, args, {
2573
2575
  assetDir = '',
2574
2576
  platform = 0
2575
2577
  } = {}) => {
@@ -2633,7 +2635,7 @@ const toProtoVisibleItem$2 = item => {
2633
2635
  value
2634
2636
  };
2635
2637
  };
2636
- const getPicks$b = async (searchValue, args) => {
2638
+ const getPicks$d = async (searchValue, args) => {
2637
2639
  state$2.args = args;
2638
2640
  const options = args.at(-1);
2639
2641
  let items;
@@ -2646,6 +2648,20 @@ const getPicks$b = async (searchValue, args) => {
2646
2648
  return mapped;
2647
2649
  };
2648
2650
 
2651
+ const toPick$1 = (label, value) => ({
2652
+ description: '',
2653
+ direntType: 0,
2654
+ fileIcon: '',
2655
+ icon: '',
2656
+ label,
2657
+ matches: [],
2658
+ uri: '',
2659
+ value
2660
+ });
2661
+ const getPicks$c = async () => {
2662
+ return [toPick$1('LF', 'lf'), toPick$1('CRLF', 'crlf')];
2663
+ };
2664
+
2649
2665
  const emptyMatches = [];
2650
2666
 
2651
2667
  const getWorkspacePath = async () => {
@@ -2695,7 +2711,7 @@ const convertToPick = uri => {
2695
2711
  // e.g. when there are many files, don't need
2696
2712
  // to compute the fileIcon for all files
2697
2713
 
2698
- const getPicks$a = async searchValue => {
2714
+ const getPicks$b = async searchValue => {
2699
2715
  // TODO cache workspace path
2700
2716
  const workspace = await getWorkspacePath();
2701
2717
  if (!workspace) {
@@ -2863,35 +2879,34 @@ const getPicksGoToLineBase = async () => {
2863
2879
  }];
2864
2880
  };
2865
2881
 
2866
- const parseGotoline = value => {
2867
- const lineString = value.slice(GoToLine$1.length);
2868
- const wantedLine = Number(lineString);
2869
- if (Number.isNaN(wantedLine)) {
2870
- return -1;
2871
- }
2872
- if (wantedLine < 1) {
2873
- return -1;
2882
+ const parseGoToLinePosition = value => {
2883
+ const [lineString, columnString = '1'] = value.slice(GoToLine$1.length).split(':');
2884
+ const line = Number(lineString);
2885
+ const column = Number(columnString);
2886
+ if (!Number.isSafeInteger(line) || !Number.isSafeInteger(column) || line < 1 || column < 1) {
2887
+ return undefined;
2874
2888
  }
2875
- return wantedLine;
2889
+ return {
2890
+ columnIndex: column - 1,
2891
+ rowIndex: line - 1
2892
+ };
2876
2893
  };
2877
2894
 
2878
- const getPicks$9 = async value => {
2895
+ const getPicks$a = async value => {
2879
2896
  if (value === GoToLine$1) {
2880
2897
  return getPicksGoToLineBase();
2881
2898
  }
2882
2899
  if (value.startsWith(GoToLine$1)) {
2883
- const wantedLine = parseGotoline(value);
2884
- if (wantedLine === -1) {
2900
+ const position = parseGoToLinePosition(value);
2901
+ if (!position) {
2885
2902
  return getPicksGoToLineBase();
2886
2903
  }
2887
- const rowIndex = wantedLine - 1;
2888
- const columnIndex = 0;
2889
2904
  return [{
2890
2905
  description: '',
2891
2906
  direntType: 0,
2892
2907
  fileIcon: '',
2893
2908
  icon: '',
2894
- label: pressEnterToGoToLine(rowIndex, columnIndex),
2909
+ label: pressEnterToGoToLine(position.rowIndex, position.columnIndex),
2895
2910
  matches: [],
2896
2911
  uri: ''
2897
2912
  }];
@@ -2905,7 +2920,7 @@ const Percent = '%';
2905
2920
  const AngleBracket = '>';
2906
2921
  const View$1 = 'view';
2907
2922
 
2908
- const getPicks$8 = async () => {
2923
+ const getPicks$9 = async () => {
2909
2924
  return [{
2910
2925
  description: goToFile(),
2911
2926
  direntType: None$2,
@@ -2957,6 +2972,20 @@ const getPicks$8 = async () => {
2957
2972
  }];
2958
2973
  };
2959
2974
 
2975
+ const toPick = (label, value) => ({
2976
+ description: '',
2977
+ direntType: 0,
2978
+ fileIcon: '',
2979
+ icon: '',
2980
+ label,
2981
+ matches: [],
2982
+ uri: '',
2983
+ value
2984
+ });
2985
+ const getPicks$8 = async () => {
2986
+ return [toPick('Indent Using Spaces', true), toPick('Indent Using Tabs', false)];
2987
+ };
2988
+
2960
2989
  const getIconName = language => {
2961
2990
  const fileName = language.fileNames?.find(value => typeof value === 'string');
2962
2991
  if (fileName) {
@@ -3099,7 +3128,7 @@ const KeepOpen = '';
3099
3128
  const OpenColorTheme = 'open-color-theme';
3100
3129
  const OpenLanguageMode = 'open-language-mode';
3101
3130
 
3102
- const selectPick$a = async pick => {
3131
+ const selectPick$c = async pick => {
3103
3132
  const id = pick.label;
3104
3133
  await setColorTheme(id);
3105
3134
  return {
@@ -3156,7 +3185,7 @@ const selectPickExtension = async item => {
3156
3185
  command: Hide
3157
3186
  };
3158
3187
  };
3159
- const selectPick$9 = async item => {
3188
+ const selectPick$b = async item => {
3160
3189
  // @ts-ignore
3161
3190
  const {
3162
3191
  id
@@ -3174,7 +3203,7 @@ const getOptions = args => {
3174
3203
  }
3175
3204
  return last;
3176
3205
  };
3177
- const selectPick$8 = async (_pick, value) => {
3206
+ const selectPick$a = async (_pick, value) => {
3178
3207
  const {
3179
3208
  args
3180
3209
  } = state$2;
@@ -3209,11 +3238,19 @@ const selectPick$8 = async (_pick, value) => {
3209
3238
  };
3210
3239
  };
3211
3240
 
3241
+ const selectPick$9 = async pick => {
3242
+ const editorId = await getActiveEditorId();
3243
+ await invoke$2('Viewlet.executeViewletCommand', editorId, 'setEndOfLine', pick.value);
3244
+ return {
3245
+ command: Hide
3246
+ };
3247
+ };
3248
+
3212
3249
  const openUri = async uri => {
3213
3250
  await openUri$1(uri);
3214
3251
  };
3215
3252
 
3216
- const selectPick$7 = async pick => {
3253
+ const selectPick$8 = async pick => {
3217
3254
  const {
3218
3255
  description
3219
3256
  } = pick;
@@ -3251,13 +3288,12 @@ const selectPickGoToColumn = async (item, value) => {
3251
3288
  };
3252
3289
  };
3253
3290
 
3254
- const selectPick$6 = async (item, value) => {
3291
+ const selectPick$7 = async (item, value) => {
3255
3292
  if (value.startsWith(GoToLine$1)) {
3256
- const lineString = value.slice(GoToLine$1.length);
3257
- const wantedLine = Number(lineString);
3258
- const rowIndex = wantedLine - 1;
3259
- const columnIndex = 0;
3260
- await goToPositionAndFocus(rowIndex, columnIndex);
3293
+ const position = parseGoToLinePosition(value);
3294
+ if (position) {
3295
+ await goToPositionAndFocus(position.rowIndex, position.columnIndex);
3296
+ }
3261
3297
  return {
3262
3298
  command: Hide
3263
3299
  };
@@ -3267,13 +3303,21 @@ const selectPick$6 = async (item, value) => {
3267
3303
  };
3268
3304
  };
3269
3305
 
3270
- const selectPick$5 = async item => {
3306
+ const selectPick$6 = async item => {
3271
3307
  // Command.execute(/* openView */ 549, /* viewName */ item.label)
3272
3308
  return {
3273
3309
  command: Hide
3274
3310
  };
3275
3311
  };
3276
3312
 
3313
+ const selectPick$5 = async pick => {
3314
+ const editorId = await getActiveEditorId();
3315
+ await invoke$2('Viewlet.executeViewletCommand', editorId, 'setIndentation', pick.value);
3316
+ return {
3317
+ command: Hide
3318
+ };
3319
+ };
3320
+
3277
3321
  const selectPick$4 = async pick => {
3278
3322
  const editorId = await getActiveEditorId();
3279
3323
  const value = pick.value;
@@ -3318,8 +3362,8 @@ const selectPick = async item => {
3318
3362
  };
3319
3363
  };
3320
3364
 
3321
- const selectPicks = [selectPick$a, selectPick$9, selectPick$8, selectPick$7, selectPickGoToColumn, selectPick$6, selectPick$5, selectPick$3, selectPick$2, selectPick$1, selectPick, selectPick$4];
3322
- const getPicks$2 = [getPicks$d, getPicks$c, getPicks$b, getPicks$a, getPicksGoToColumn, getPicks$9, getPicks$8, getPicks$6, getPicks$5, getPicks$4, getPicks$3, getPicks$7];
3365
+ const selectPicks = [selectPick$c, selectPick$b, selectPick$a, selectPick$8, selectPickGoToColumn, selectPick$7, selectPick$6, selectPick$3, selectPick$2, selectPick$1, selectPick, selectPick$4, selectPick$9, selectPick$5];
3366
+ const getPicks$2 = [getPicks$f, getPicks$e, getPicks$d, getPicks$b, getPicksGoToColumn, getPicks$a, getPicks$9, getPicks$6, getPicks$5, getPicks$4, getPicks$3, getPicks$7, getPicks$c, getPicks$8];
3323
3367
 
3324
3368
  const select = selectPicks;
3325
3369
  const getPick$1 = getPicks$2;
@@ -3565,9 +3609,16 @@ const Help = 'quickPick://help';
3565
3609
  const WorkspaceSymbol = 'quickPick://workspace-symbol';
3566
3610
  const Custom = 'quickPick://custom';
3567
3611
  const GoToLine = 'quickPick://go-to-line';
3612
+ const EndOfLine = 'quickPick://end-of-line';
3613
+ const Indentation = 'quickPick://indentation';
3568
3614
 
3569
- const getDefaultValue = (id, uri = '') => {
3615
+ const getDefaultValue = (id, uri = '', args = []) => {
3570
3616
  if (uri === GoToLine) {
3617
+ const line = Number(args[1]);
3618
+ const column = Number(args[2]);
3619
+ if (Number.isSafeInteger(line) && Number.isSafeInteger(column) && line >= 1 && column >= 1) {
3620
+ return `${GoToLine$1}${line}:${column}`;
3621
+ }
3571
3622
  return GoToLine$1;
3572
3623
  }
3573
3624
  if (uri === WorkspaceSymbol) {
@@ -3595,6 +3646,10 @@ const getQuickPickProviderId = prefix => {
3595
3646
  return EveryThing$1;
3596
3647
  case Custom:
3597
3648
  return Custom$1;
3649
+ case EndOfLine:
3650
+ return EndOfLine$1;
3651
+ case Indentation:
3652
+ return Indentation$1;
3598
3653
  case LanguageMode:
3599
3654
  return LanguageMode$1;
3600
3655
  case Recent:
@@ -3658,7 +3713,7 @@ const getLoadedState = async state => {
3658
3713
  uri
3659
3714
  } = state;
3660
3715
  const id = getQuickPickProviderId(uri);
3661
- const value = getDefaultValue(id, uri);
3716
+ const value = getDefaultValue(id, uri, args);
3662
3717
  const prefix = getQuickPickPrefix(value);
3663
3718
  const subId = getQuickPickSubProviderId(id, prefix);
3664
3719
  const newPicks = await getPicks(subId, value, args, {
@@ -4749,6 +4804,30 @@ const selectItem = async (state, label) => {
4749
4804
  return selectIndex(state, index);
4750
4805
  };
4751
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
+
4752
4831
  const showQuickInput = async ({
4753
4832
  id,
4754
4833
  ignoreFocusOut,
@@ -4827,7 +4906,7 @@ const commandMap = {
4827
4906
  'QuickPick.handleBlur': wrapCommand(handleBlur),
4828
4907
  'QuickPick.handleClickAt': wrapCommand(handleClickAt),
4829
4908
  'QuickPick.handleFocus': wrapCommand(handleFocus),
4830
- 'QuickPick.handleInput': wrapAsyncCommand(handleInputWithContext),
4909
+ 'QuickPick.handleInput': serialize(wrapAsyncCommand(handleInputWithContext)),
4831
4910
  'QuickPick.handleMessagePort': handleMessagePort,
4832
4911
  'QuickPick.handleRendererProcessMessagePort': handleDirectMessagePort,
4833
4912
  'QuickPick.handleScrollBarPointerDown': wrapCommand(handleScrollBarPointerDown),
@@ -4838,7 +4917,7 @@ const commandMap = {
4838
4917
  'QuickPick.loadContent': wrapAsyncCommand(loadContentWithContext),
4839
4918
  'QuickPick.render2': render2,
4840
4919
  'QuickPick.renderEventListeners': renderEventListeners,
4841
- 'QuickPick.selectCurrentIndex': wrapCommand(selectCurrentIndex),
4920
+ 'QuickPick.selectCurrentIndex': serialize(wrapCommand(selectCurrentIndex)),
4842
4921
  'QuickPick.selectIndex': wrapCommand(selectIndex),
4843
4922
  'QuickPick.selectItem': wrapCommand(selectItem),
4844
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.17.2",
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"