@lvce-editor/text-search-view 1.4.0 → 1.6.5

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.
@@ -2076,9 +2076,13 @@ const getFilePath = text => {
2076
2076
  return text;
2077
2077
  };
2078
2078
 
2079
+ const File = 1;
2080
+ const Match = 2;
2081
+ const Context = 3;
2082
+
2079
2083
  const getIconsCached = (dirents, fileIconCache) => {
2080
2084
  return dirents.map(dirent => {
2081
- if (dirent.type === Match$1) {
2085
+ if (dirent.type !== File) {
2082
2086
  return '';
2083
2087
  }
2084
2088
  const path = getFilePath(dirent.text);
@@ -2094,9 +2098,6 @@ const getFileName = path => {
2094
2098
  return path.slice(slashIndex + 1);
2095
2099
  };
2096
2100
 
2097
- const File = 1;
2098
- const Match = 2;
2099
-
2100
2101
  const isFile = match => {
2101
2102
  return match.type === File;
2102
2103
  };
@@ -2190,7 +2191,7 @@ const getFilteredResults = (results, collapsedPaths) => {
2190
2191
  filteredResults.push(result);
2191
2192
  isExcluded = collapsedPaths.includes(result.text) ? true : false;
2192
2193
  }
2193
- if (result.type === Match && !isExcluded) {
2194
+ if ((result.type === Match || result.type === Context) && !isExcluded) {
2194
2195
  filteredResults.push(result);
2195
2196
  }
2196
2197
  }
@@ -2291,6 +2292,9 @@ const hasReplaceExpanded = flags => {
2291
2292
  const hasDetailsExpanded = flags => {
2292
2293
  return (flags & DetailsExpanded) === DetailsExpanded;
2293
2294
  };
2295
+ const hasOpenEditors = flags => {
2296
+ return (flags & OpenEditors) === OpenEditors;
2297
+ };
2294
2298
  const hasUseIgnoreFiles = flags => {
2295
2299
  return (flags & UseIgnoreFiles) === UseIgnoreFiles;
2296
2300
  };
@@ -2418,7 +2422,6 @@ const copyPath$1 = async state => {
2418
2422
  };
2419
2423
 
2420
2424
  const defaultExcludes = ['.git', 'node_modules'];
2421
- defaultExcludes.join(',');
2422
2425
 
2423
2426
  const minimumSliderSize = 20;
2424
2427
 
@@ -2547,16 +2550,6 @@ const isEqual$7 = (oldState, newState) => {
2547
2550
  return oldState.deltaY === newState.deltaY && oldState.finalDeltaY === newState.finalDeltaY && oldState.height === newState.height && oldState.headerHeight === newState.headerHeight && oldState.itemHeight === newState.itemHeight && oldState.items === newState.items;
2548
2551
  };
2549
2552
 
2550
- const RenderFocus = 2;
2551
- const RenderValue = 3;
2552
- const RenderReplaceValue = 4;
2553
- const RenderIncludeValue = 5;
2554
- const RenderExcludeValue = 6;
2555
- const RenderFocusContext = 7;
2556
- const RenderSelections = 8;
2557
- const RenderIncremental = 9;
2558
- const RenderCss = 10;
2559
-
2560
2553
  const isEqual$6 = (oldState, newState) => {
2561
2554
  return oldState.excludeValue === newState.excludeValue || newState.inputSource === User;
2562
2555
  };
@@ -2581,6 +2574,16 @@ const isEqual$1 = (oldState, newState) => {
2581
2574
  return oldState.replacement === newState.replacement || newState.inputSource === User;
2582
2575
  };
2583
2576
 
2577
+ const RenderFocus = 2;
2578
+ const RenderValue = 3;
2579
+ const RenderReplaceValue = 4;
2580
+ const RenderIncludeValue = 5;
2581
+ const RenderExcludeValue = 6;
2582
+ const RenderFocusContext = 7;
2583
+ const RenderSelections = 8;
2584
+ const RenderIncremental = 9;
2585
+ const RenderCss = 10;
2586
+
2584
2587
  const isEqual = (oldState, newState) => {
2585
2588
  return oldState.value === newState.value || newState.inputSource === User;
2586
2589
  };
@@ -2649,12 +2652,25 @@ const getSetSize = (items, index) => {
2649
2652
  }
2650
2653
  return setSize;
2651
2654
  };
2655
+ const getMatchCount$1 = (items, index) => {
2656
+ let matchCount = 0;
2657
+ for (let i = index + 1; i < items.length; i++) {
2658
+ if (items[i].type === File) {
2659
+ break;
2660
+ }
2661
+ if (items[i].type === Match) {
2662
+ matchCount++;
2663
+ }
2664
+ }
2665
+ return matchCount;
2666
+ };
2652
2667
  const getRemoveIndicesFile = (items, item, index, matchCount, fileCount) => {
2653
2668
  const setSize = getSetSize(items, index);
2669
+ const removedMatchCount = getMatchCount$1(items, index);
2654
2670
  return {
2655
2671
  newFileCount: fileCount - 1,
2656
2672
  newFocusedIndex: index + setSize + 1 < items.length ? index : index - 1,
2657
- newMatchCount: matchCount - setSize,
2673
+ newMatchCount: matchCount - removedMatchCount,
2658
2674
  removeCount: setSize + 1,
2659
2675
  startIndex: index
2660
2676
  };
@@ -2683,9 +2699,20 @@ const getRemoveIndicesMatch = (items, index, matchCount, fileCount) => {
2683
2699
  }
2684
2700
  throw new Error('could not compute indices to remove');
2685
2701
  };
2702
+ const getRemoveIndicesContext = (index, matchCount, fileCount) => {
2703
+ return {
2704
+ newFileCount: fileCount,
2705
+ newFocusedIndex: index,
2706
+ newMatchCount: matchCount,
2707
+ removeCount: 1,
2708
+ startIndex: index
2709
+ };
2710
+ };
2686
2711
  const getRemoveIndices = (items, index, matchCount, fileCount) => {
2687
2712
  const item = items[index];
2688
2713
  switch (item.type) {
2714
+ case Context:
2715
+ return getRemoveIndicesContext(index, matchCount, fileCount);
2689
2716
  case File:
2690
2717
  return getRemoveIndicesFile(items, item, index, matchCount, fileCount);
2691
2718
  case Match:
@@ -3593,7 +3620,14 @@ const getTextSearchResultCounts = results => {
3593
3620
  };
3594
3621
 
3595
3622
  const textSearch = async (root, query, options, assetDir, platform, searchId, uid) => {
3596
- return search$1(root, query, options, assetDir, platform, searchId, uid);
3623
+ if (!hasOpenEditors(options.flags)) {
3624
+ return search$1(root, query, options, assetDir, platform, searchId, uid);
3625
+ }
3626
+ const openEditorUris = await invoke$1('GetActiveEditor.getOpenEditorUris');
3627
+ return search$1(root, query, {
3628
+ ...options,
3629
+ openEditorUris
3630
+ }, assetDir, platform, searchId, uid);
3597
3631
  };
3598
3632
 
3599
3633
  const handleUpdateFull = async (state, update) => {
@@ -3606,6 +3640,8 @@ const handleUpdateFull = async (state, update) => {
3606
3640
  };
3607
3641
  const {
3608
3642
  assetDir,
3643
+ contextLines,
3644
+ contextLinesEnabled,
3609
3645
  excludeValue,
3610
3646
  fileIconCache,
3611
3647
  flags,
@@ -3631,6 +3667,7 @@ const handleUpdateFull = async (state, update) => {
3631
3667
  results
3632
3668
  } = await textSearch(root, value, {
3633
3669
  assetDir,
3670
+ contextLines: contextLinesEnabled ? contextLines : 0,
3634
3671
  defaultExcludes: hasUseIgnoreFiles(flags) ? partialNewState.defaultExcludes : [],
3635
3672
  exclude: excludeValue,
3636
3673
  flags,
@@ -3749,6 +3786,8 @@ const handleUpdateIncremental = async (state, update) => {
3749
3786
  };
3750
3787
  const {
3751
3788
  assetDir,
3789
+ contextLines,
3790
+ contextLinesEnabled,
3752
3791
  excludeValue,
3753
3792
  flags,
3754
3793
  includeValue,
@@ -3773,6 +3812,7 @@ const handleUpdateIncremental = async (state, update) => {
3773
3812
  // TODO await promise?
3774
3813
  void textSearchIncremental(root, value, {
3775
3814
  assetDir: assetDir,
3815
+ contextLines: contextLinesEnabled ? contextLines : 0,
3776
3816
  defaultExcludes: hasUseIgnoreFiles(flags) ? partialNewState.defaultExcludes : [],
3777
3817
  exclude: excludeValue,
3778
3818
  flags,
@@ -3812,6 +3852,8 @@ const handleUpdatePullBased = async (state, update) => {
3812
3852
  set(previousUid, state, partialNewState);
3813
3853
  const {
3814
3854
  assetDir,
3855
+ contextLines,
3856
+ contextLinesEnabled,
3815
3857
  excludeValue,
3816
3858
  flags,
3817
3859
  includeValue,
@@ -3831,6 +3873,7 @@ const handleUpdatePullBased = async (state, update) => {
3831
3873
  limitHit
3832
3874
  } = await textSearch(root, value, {
3833
3875
  assetDir,
3876
+ contextLines: contextLinesEnabled ? contextLines : 0,
3834
3877
  defaultExcludes: hasUseIgnoreFiles(flags) ? partialNewState.defaultExcludes : [],
3835
3878
  exclude: excludeValue,
3836
3879
  flags,
@@ -4001,8 +4044,10 @@ const getReplaceElements = (items, workspacePath, replacement) => {
4001
4044
  for (const match of items) {
4002
4045
  const {
4003
4046
  end,
4047
+ endColumnIndex,
4004
4048
  lineNumber,
4005
4049
  start,
4050
+ startColumnIndex,
4006
4051
  text,
4007
4052
  type
4008
4053
  } = match;
@@ -4014,11 +4059,11 @@ const getReplaceElements = (items, workspacePath, replacement) => {
4014
4059
  changes,
4015
4060
  uri: absolutePath
4016
4061
  });
4017
- } else {
4062
+ } else if (type === Match) {
4018
4063
  changes.push({
4019
- endColumnIndex: end,
4064
+ endColumnIndex: endColumnIndex ?? end,
4020
4065
  endRowIndex: lineNumber,
4021
- startColumnIndex: start,
4066
+ startColumnIndex: startColumnIndex ?? start,
4022
4067
  startRowIndex: lineNumber - 1,
4023
4068
  text: replacement
4024
4069
  });
@@ -4724,13 +4769,15 @@ const handleListBlur = state => {
4724
4769
 
4725
4770
  const handleListFocus = async state => {
4726
4771
  const {
4772
+ focus,
4727
4773
  listFocused
4728
4774
  } = state;
4729
- if (listFocused) {
4775
+ if (focus === FocusSearchResults && listFocused) {
4730
4776
  return state;
4731
4777
  }
4732
4778
  return {
4733
4779
  ...state,
4780
+ focus: FocusSearchResults,
4734
4781
  listFocused: true
4735
4782
  };
4736
4783
  };
@@ -5283,6 +5330,8 @@ const selectIndexPreview = async (state, searchResult, index) => {
5283
5330
 
5284
5331
  const getSelectHandler = type => {
5285
5332
  switch (type) {
5333
+ case Context:
5334
+ return selectIndexPreview;
5286
5335
  case File:
5287
5336
  return selectIndexFile;
5288
5337
  case Match:
@@ -5565,13 +5614,17 @@ const Collapsed = 1;
5565
5614
  const Expanded = 2;
5566
5615
 
5567
5616
  const getMatchCount = (results, startIndex) => {
5617
+ let matchCount = 0;
5568
5618
  for (let i = startIndex + 1; i < results.length; i++) {
5569
5619
  const result = results[i];
5570
5620
  if (result.type === File) {
5571
- return i - startIndex - 1;
5621
+ break;
5622
+ }
5623
+ if (result.type === Match) {
5624
+ matchCount++;
5572
5625
  }
5573
5626
  }
5574
- return results.length - startIndex - 1;
5627
+ return matchCount;
5575
5628
  };
5576
5629
 
5577
5630
  const defaultIndent = 12;
@@ -5640,6 +5693,8 @@ const getDisplayResult = (results, fileIcons, i, setSize, searchTermLength, repl
5640
5693
  const focused = i === focusedIndex;
5641
5694
  const relativeIndex = i - minLineY;
5642
5695
  switch (type) {
5696
+ case Context:
5697
+ return getDisplayResultMatch(setSize, 0, '', text, posInSet, 0, focused);
5643
5698
  case File:
5644
5699
  return getSearchDisplayResultFile(results, fileIcons, i, setSize, collapsedPaths, text, posInSet, relativeIndex, focused, renderFolderPaths, originalResults);
5645
5700
  case Match:
@@ -5890,8 +5945,8 @@ const getSearchHeaderDetailsCollapsedVirtualDom = message => {
5890
5945
 
5891
5946
  const CheckBoxEnabled = 1;
5892
5947
  const CheckBoxDisabled = 2;
5893
- const ButtonEnabled = 2;
5894
- const ButtonDisabled = 3;
5948
+ const ButtonEnabled = 3;
5949
+ const ButtonDisabled = 4;
5895
5950
 
5896
5951
  const getInputActionsExclude = flags => {
5897
5952
  const inside = [{
@@ -6469,12 +6524,12 @@ const getSearchResultsVirtualDom = (visibleItems, focusOutline, scrollbarHeight,
6469
6524
  childCount,
6470
6525
  className: mergeClassNames(Viewlet, List$1, Tree, focusOutline ? FocusOutline : Empty$1),
6471
6526
  onBlur: HandleListBlur,
6527
+ onFocus: HandleListFocus,
6472
6528
  role: Tree$1,
6473
6529
  tabIndex: Focusable,
6474
6530
  type: Div
6475
6531
  // TODO renable this when dom diffing is supported
6476
6532
  // onPointerDown: HandleListPointerDown,
6477
- // onFocus: HandleListFocus,
6478
6533
  }, ...getTreeItemsVirtualDom(visibleItems, deltaY, itemHeight), ...getScrollBarVirtualDom(scrollbarHeight, scrollBarY, scrollBarValue)];
6479
6534
  };
6480
6535
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/text-search-view",
3
- "version": "1.4.0",
3
+ "version": "1.6.5",
4
4
  "description": "Text Search View",
5
5
  "keywords": [
6
6
  "text-search"