@lvce-editor/quick-pick-worker 4.27.0 → 4.28.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.
@@ -2329,6 +2329,78 @@ const getNewValue = (value, inputType, data, selectionStart, selectionEnd) => {
2329
2329
  return fn(value, selectionStart, selectionEnd, data);
2330
2330
  };
2331
2331
 
2332
+ const Command = '>';
2333
+ const Symbol$2 = '@';
2334
+ const WorkspaceSymbol$1 = '#';
2335
+ const GoToLine$1 = ':';
2336
+ const View$2 = 'view ';
2337
+ const None$1 = '';
2338
+ const Help$1 = '?';
2339
+ const GoToColumn = '::';
2340
+
2341
+ const getQuickPickPrefix = value => {
2342
+ if (value.startsWith(Command)) {
2343
+ return Command;
2344
+ }
2345
+ if (value.startsWith(Symbol$2)) {
2346
+ return Symbol$2;
2347
+ }
2348
+ if (value.startsWith(WorkspaceSymbol$1)) {
2349
+ return WorkspaceSymbol$1;
2350
+ }
2351
+ if (value.startsWith(GoToColumn)) {
2352
+ return GoToColumn;
2353
+ }
2354
+ if (value.startsWith(GoToLine$1)) {
2355
+ return GoToLine$1;
2356
+ }
2357
+ if (value.startsWith(View$2)) {
2358
+ return View$2;
2359
+ }
2360
+ return None$1;
2361
+ };
2362
+
2363
+ const getQuickPickSubProviderId = (id, prefix) => {
2364
+ if (id === File$1) {
2365
+ return prefix === Command ? Commands$1 : File$1;
2366
+ }
2367
+ if (id !== EveryThing$1) {
2368
+ return id;
2369
+ }
2370
+ switch (prefix) {
2371
+ case Command:
2372
+ return Commands$1;
2373
+ case GoToColumn:
2374
+ return GoToColumn$1;
2375
+ case GoToLine$1:
2376
+ return GoToLine$2;
2377
+ case Help$1:
2378
+ return Help$2;
2379
+ case Symbol$2:
2380
+ return Symbol$3;
2381
+ case View$2:
2382
+ return View$3;
2383
+ case WorkspaceSymbol$1:
2384
+ return WorkspaceSymbol$2;
2385
+ default:
2386
+ return File$1;
2387
+ }
2388
+ };
2389
+
2390
+ // Keep this aligned with file-search-worker's SearchFileWithRipGrep limit.
2391
+ const maxFileSearchResults = 9_999_999;
2392
+ const canReuseFilePicks = (providerId, previousValue, newValue, pickCount) => {
2393
+ if (providerId !== File$1 && providerId !== EveryThing$1) {
2394
+ return false;
2395
+ }
2396
+ if (newValue.length <= previousValue.length || !newValue.startsWith(previousValue)) {
2397
+ return false;
2398
+ }
2399
+ const previousSubProviderId = getQuickPickSubProviderId(providerId, getQuickPickPrefix(previousValue));
2400
+ const newSubProviderId = getQuickPickSubProviderId(providerId, getQuickPickPrefix(newValue));
2401
+ return previousSubProviderId === File$1 && newSubProviderId === File$1 && pickCount < maxFileSearchResults;
2402
+ };
2403
+
2332
2404
  const Diagonal = 1;
2333
2405
  const Left = 2;
2334
2406
 
@@ -2553,37 +2625,6 @@ const filterQuickPickItems = (items, value, rankCommands = false) => {
2553
2625
  return rankCommands ? rankCommandPicks(results, value) : results;
2554
2626
  };
2555
2627
 
2556
- const Command = '>';
2557
- const Symbol$2 = '@';
2558
- const WorkspaceSymbol$1 = '#';
2559
- const GoToLine$1 = ':';
2560
- const View$2 = 'view ';
2561
- const None$1 = '';
2562
- const Help$1 = '?';
2563
- const GoToColumn = '::';
2564
-
2565
- const getQuickPickPrefix = value => {
2566
- if (value.startsWith(Command)) {
2567
- return Command;
2568
- }
2569
- if (value.startsWith(Symbol$2)) {
2570
- return Symbol$2;
2571
- }
2572
- if (value.startsWith(WorkspaceSymbol$1)) {
2573
- return WorkspaceSymbol$1;
2574
- }
2575
- if (value.startsWith(GoToColumn)) {
2576
- return GoToColumn;
2577
- }
2578
- if (value.startsWith(GoToLine$1)) {
2579
- return GoToLine$1;
2580
- }
2581
- if (value.startsWith(View$2)) {
2582
- return View$2;
2583
- }
2584
- return None$1;
2585
- };
2586
-
2587
2628
  const noop = value => {
2588
2629
  return value;
2589
2630
  };
@@ -2902,9 +2943,8 @@ const invoke$2 = (method, ...args) => {
2902
2943
 
2903
2944
  const cacheName = 'quick-pick-files-v1';
2904
2945
  const cacheUrl = workspace => {
2905
- const url = new URL('https://quick-pick-cache.invalid/cache/v1');
2906
- url.searchParams.set('folder', workspace);
2907
- return url.href;
2946
+ const path = workspace.replaceAll('\\', '/').replace(/^\/+/, '').split('/').map(encodeURIComponent).join('/');
2947
+ return `https://quick-pick-cache.invalid/cache/v1/file/${path}`;
2908
2948
  };
2909
2949
  const isEntry = value => {
2910
2950
  if (!value || typeof value !== 'object') {
@@ -2931,12 +2971,15 @@ const get = async workspace => {
2931
2971
  };
2932
2972
  const set$1 = async (workspace, entry) => {
2933
2973
  const expires = new Date(Date.now() + 90 * 24 * 60 * 60 * 1000).toUTCString();
2974
+ const body = JSON.stringify(entry);
2934
2975
  const headers = {
2935
2976
  'cache-control': 'private, max-age=7776000',
2977
+ 'content-length': String(new TextEncoder().encode(body).byteLength),
2978
+ 'content-type': 'application/json',
2936
2979
  expires
2937
2980
  };
2938
2981
  try {
2939
- await invoke$2('Cache.setCacheStorageItem', cacheUrl(workspace), JSON.stringify(entry), cacheName, headers);
2982
+ await invoke$2('Cache.setCacheStorageItem', cacheUrl(workspace), body, cacheName, headers);
2940
2983
  } catch {
2941
2984
  // Caching is optional; a storage failure must not break file search.
2942
2985
  }
@@ -3751,33 +3794,6 @@ const getPicks = (id, searchValue, args, {
3751
3794
  });
3752
3795
  };
3753
3796
 
3754
- const getQuickPickSubProviderId = (id, prefix) => {
3755
- if (id === File$1) {
3756
- return prefix === Command ? Commands$1 : File$1;
3757
- }
3758
- if (id !== EveryThing$1) {
3759
- return id;
3760
- }
3761
- switch (prefix) {
3762
- case Command:
3763
- return Commands$1;
3764
- case GoToColumn:
3765
- return GoToColumn$1;
3766
- case GoToLine$1:
3767
- return GoToLine$2;
3768
- case Help$1:
3769
- return Help$2;
3770
- case Symbol$2:
3771
- return Symbol$3;
3772
- case View$2:
3773
- return View$3;
3774
- case WorkspaceSymbol$1:
3775
- return WorkspaceSymbol$2;
3776
- default:
3777
- return File$1;
3778
- }
3779
- };
3780
-
3781
3797
  const requestVersions = new Map();
3782
3798
  const requestVersionGenerator = {
3783
3799
  value: 0
@@ -3793,8 +3809,6 @@ const isStaticQuickInput = args => {
3793
3809
  const options = args.at(-1);
3794
3810
  return options?.mode === 'quickInput' && options.quickInputId === undefined;
3795
3811
  };
3796
-
3797
- // TODO when user types letters -> no need to query provider again -> just filter existing results
3798
3812
  const setValue = async (state, newValue) => {
3799
3813
  const {
3800
3814
  args,
@@ -3821,7 +3835,8 @@ const setValue = async (state, newValue) => {
3821
3835
  const prefix = getQuickPickPrefix(newValue);
3822
3836
  const subId = getQuickPickSubProviderId(providerId, prefix);
3823
3837
  const quickInput = isQuickInput(args);
3824
- const newPicks = isStaticQuickInput(args) || subId === LanguageMode$1 ? state.picks : await getPicks(subId, newValue, args, {
3838
+ const reuseFilePicks = !state.initial && canReuseFilePicks(providerId, value, newValue, state.picks.length);
3839
+ const newPicks = isStaticQuickInput(args) || subId === LanguageMode$1 || reuseFilePicks ? state.picks : await getPicks(subId, newValue, args, {
3825
3840
  applicationId: state.applicationId,
3826
3841
  assetDir,
3827
3842
  platform
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/quick-pick-worker",
3
- "version": "4.27.0",
3
+ "version": "4.28.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/lvce-editor/quick-pick-worker.git"