@lvce-editor/text-search-worker 6.2.0 → 6.4.0

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.
@@ -1306,9 +1306,10 @@ const File$1 = 1;
1306
1306
  const Match$1 = 2;
1307
1307
 
1308
1308
  const FocusElementByName = 'Viewlet.focusElementByName';
1309
- const SetDom2 = 'Viewlet.setDom2';
1309
+ const SetCss = 'Viewlet.setCss';
1310
1310
  const SetFocusContext = 'Viewlet.setFocusContext';
1311
1311
  const SetValueByName = 'Viewlet.setValueByName';
1312
+ const SetPatches = 'Viewlet.setPatches';
1312
1313
 
1313
1314
  const Empty = 0;
1314
1315
  const FocusIgnoreFiles = 1012;
@@ -2187,7 +2188,10 @@ const create = (uid, x, y, width, height, workspacePath, assetDir, itemHeight, v
2187
2188
  return state;
2188
2189
  };
2189
2190
 
2190
- const RenderItems = 1;
2191
+ const isEqual$7 = (oldState, newState) => {
2192
+ 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;
2193
+ };
2194
+
2191
2195
  const RenderFocus = 2;
2192
2196
  const RenderValue = 3;
2193
2197
  const RenderReplaceValue = 4;
@@ -2196,6 +2200,7 @@ const RenderExcludeValue = 6;
2196
2200
  const RenderFocusContext = 7;
2197
2201
  const RenderSelections = 8;
2198
2202
  const RenderIncremental = 9;
2203
+ const RenderCss = 10;
2199
2204
 
2200
2205
  const isEqual$6 = (oldState, newState) => {
2201
2206
  return oldState.excludeValue === newState.excludeValue || newState.inputSource === User;
@@ -2214,7 +2219,7 @@ const isEqual$3 = (oldState, newState) => {
2214
2219
  };
2215
2220
 
2216
2221
  const isEqual$2 = (oldState, newState) => {
2217
- return oldState.collapsedPaths === newState.collapsedPaths && oldState.deltaY === newState.deltaY && oldState.flags === newState.flags && oldState.focus === newState.focus && oldState.icons === newState.icons && oldState.items === newState.items && oldState.listFocused === newState.listFocused && oldState.listFocusedIndex === newState.listFocusedIndex && oldState.loaded === newState.loaded && oldState.maxLineY === newState.maxLineY && oldState.message === newState.message && oldState.minLineY === newState.minLineY && oldState.replacement === newState.replacement && oldState.searchInputErrorMessage === newState.searchInputErrorMessage;
2222
+ return oldState.collapsedPaths === newState.collapsedPaths && oldState.deltaY === newState.deltaY && oldState.flags === newState.flags && oldState.focus === newState.focus && oldState.icons === newState.icons && oldState.items === newState.items && oldState.listFocused === newState.listFocused && oldState.listFocusedIndex === newState.listFocusedIndex && oldState.loaded === newState.loaded && oldState.maxLineY === newState.maxLineY && oldState.message === newState.message && oldState.minLineY === newState.minLineY && oldState.renderFolderPaths === newState.renderFolderPaths && oldState.replacement === newState.replacement && oldState.searchInputErrorMessage === newState.searchInputErrorMessage;
2218
2223
  };
2219
2224
 
2220
2225
  const isEqual$1 = (oldState, newState) => {
@@ -2225,8 +2230,8 @@ const isEqual = (oldState, newState) => {
2225
2230
  return oldState.value === newState.value || newState.inputSource === User;
2226
2231
  };
2227
2232
 
2228
- const modules = [isEqual$2, isEqual$5, isEqual$3, isEqual$6, isEqual$1, isEqual, isEqual$4];
2229
- const numbers = [RenderIncremental, RenderFocus, RenderIncludeValue, RenderExcludeValue, RenderReplaceValue, RenderValue, RenderFocusContext];
2233
+ const modules = [isEqual$2, isEqual$5, isEqual$3, isEqual$6, isEqual$1, isEqual, isEqual$4, isEqual$7];
2234
+ const numbers = [RenderIncremental, RenderFocus, RenderIncludeValue, RenderExcludeValue, RenderReplaceValue, RenderValue, RenderFocusContext, RenderCss];
2230
2235
 
2231
2236
  const diff = (oldState, newState) => {
2232
2237
  const diffResult = [];
@@ -2248,6 +2253,13 @@ const diff2 = uid => {
2248
2253
  return diffResult;
2249
2254
  };
2250
2255
 
2256
+ const disableRenderFolderPaths = state => {
2257
+ return {
2258
+ ...state,
2259
+ renderFolderPaths: false
2260
+ };
2261
+ };
2262
+
2251
2263
  const getNewMinMax = (newItemsLength, minLineY, maxLineY, deltaY, itemHeight) => {
2252
2264
  if (maxLineY > newItemsLength) {
2253
2265
  const diff = maxLineY - minLineY;
@@ -2652,6 +2664,13 @@ const dismissItem = state => {
2652
2664
  return removeIndex(state, actualIndex);
2653
2665
  };
2654
2666
 
2667
+ const enableRenderFolderPaths = state => {
2668
+ return {
2669
+ ...state,
2670
+ renderFolderPaths: true
2671
+ };
2672
+ };
2673
+
2655
2674
  const expandDetails = state => {
2656
2675
  const {
2657
2676
  flags
@@ -4095,11 +4114,71 @@ const handlePullResultsFound = async (state, resultSearchId) => {
4095
4114
  return state;
4096
4115
  };
4097
4116
 
4117
+ const clamp$1 = (num, min, max) => {
4118
+ return Math.min(Math.max(num, min), max);
4119
+ };
4120
+
4121
+ const handleResize = async (state, x, y, width, height) => {
4122
+ const {
4123
+ deltaY,
4124
+ fileIconCache,
4125
+ headerHeight,
4126
+ itemHeight,
4127
+ listItems,
4128
+ minimumSliderSize
4129
+ } = state;
4130
+ const total = listItems.length;
4131
+ const contentHeight = total * itemHeight;
4132
+ const listHeight = height - headerHeight;
4133
+ const scrollBarHeight = getScrollBarSize$1(height, contentHeight, minimumSliderSize);
4134
+ const finalDeltaY = Math.max(contentHeight - listHeight, 0);
4135
+ const newDeltaY = clamp$1(deltaY, 0, finalDeltaY);
4136
+ const minLineY = Math.floor(newDeltaY / itemHeight);
4137
+ const numberOfVisible = getNumberOfVisibleItems$1(listHeight, itemHeight);
4138
+ const maxLineY = Math.min(minLineY + numberOfVisible, total);
4139
+ const visibleItems = listItems.slice(minLineY, maxLineY);
4140
+ const {
4141
+ icons,
4142
+ newFileIconCache
4143
+ } = await getFileIcons(visibleItems, fileIconCache);
4144
+ const scrollBarY = finalDeltaY === 0 ? 0 : getScrollBarY$1(newDeltaY, finalDeltaY, listHeight, scrollBarHeight);
4145
+ return {
4146
+ ...state,
4147
+ deltaY: newDeltaY,
4148
+ fileIconCache: newFileIconCache,
4149
+ finalDeltaY,
4150
+ height,
4151
+ icons,
4152
+ maxLineY,
4153
+ minLineY,
4154
+ scrollBarHeight,
4155
+ scrollBarY,
4156
+ width,
4157
+ x,
4158
+ y
4159
+ };
4160
+ };
4161
+
4098
4162
  const handleSharedInput = (state, name, value, inputSource = Script) => {
4099
4163
  const fn = getInputHandler(name);
4100
4164
  return fn(state, value, inputSource);
4101
4165
  };
4102
4166
 
4167
+ const handleWorkspaceChange = state => {
4168
+ return {
4169
+ ...state,
4170
+ deltaY: 0,
4171
+ items: [],
4172
+ listItems: [],
4173
+ matchCount: 0,
4174
+ maxLineY: 0,
4175
+ message: '',
4176
+ minLineY: 0,
4177
+ replacement: '',
4178
+ value: ''
4179
+ };
4180
+ };
4181
+
4103
4182
  const send = async port => {
4104
4183
  await sendMessagePortToIconThemeWorker(port, 0);
4105
4184
  };
@@ -4554,6 +4633,14 @@ const getRelativePath = relativePath => {
4554
4633
  }
4555
4634
  return `/${relativePath}`; // TODO support windows paths
4556
4635
  };
4636
+ const getRelativeFolderPath = relativePath => {
4637
+ const normalized = relativePath.startsWith('./') ? relativePath.slice(2) : relativePath;
4638
+ const slashIndex = normalized.lastIndexOf('/');
4639
+ if (slashIndex === -1) {
4640
+ return '';
4641
+ }
4642
+ return normalized.slice(0, slashIndex);
4643
+ };
4557
4644
 
4558
4645
  const selectIndexPreview = async (state, searchResult, index) => {
4559
4646
  const {
@@ -4828,50 +4915,6 @@ const removeCurrent = async state => {
4828
4915
  return removeIndex(state, actualIndex);
4829
4916
  };
4830
4917
 
4831
- const getFocusSelector = focusKey => {
4832
- switch (focusKey) {
4833
- case FocusIgnoreFiles:
4834
- return UseExcludeSettings;
4835
- case FocusSearchExcludeInput:
4836
- return FilesToExclude;
4837
- case FocusSearchIncludeInput:
4838
- return FilesToInclude;
4839
- case FocusSearchInput:
4840
- return SearchValue;
4841
- case FocusSearchMatchCase:
4842
- return MatchCase;
4843
- case FocusSearchOpenEditors:
4844
- return SearchOnlyOpenEditors;
4845
- case FocusSearchPreserveCase:
4846
- return PreserveCase;
4847
- case FocusSearchRegex:
4848
- return UseRegularExpression;
4849
- case FocusSearchReplaceAll:
4850
- return ReplaceAll;
4851
- case FocusSearchReplaceInput:
4852
- return ReplaceValue;
4853
- case FocusSearchResults:
4854
- return '.Tree';
4855
- case FocusSearchWholeWord:
4856
- return MatchWholeWord;
4857
- case FocusToggleDetails:
4858
- return ToggleSearchDetails;
4859
- case FocusToggleReplace:
4860
- return ToggleReplace;
4861
- default:
4862
- return '';
4863
- }
4864
- };
4865
-
4866
- const renderFocus = (oldState, newState) => {
4867
- const selector = getFocusSelector(newState.focus);
4868
- return [FocusElementByName, newState.uid, selector];
4869
- };
4870
-
4871
- const renderFocusContext = (oldState, newState) => {
4872
- return [SetFocusContext, newState.uid, FocusSearch, newState.focus];
4873
- };
4874
-
4875
4918
  const None = 0;
4876
4919
  const Collapsed = 1;
4877
4920
  const Expanded = 2;
@@ -4886,37 +4929,51 @@ const getMatchCount = (results, startIndex) => {
4886
4929
  return results.length - startIndex - 1;
4887
4930
  };
4888
4931
 
4889
- const getSearchDisplayResultFile = (results, fileIcons, i, setSize, collapsedPaths, text, posInSet, relativeIndex, focused, originalResults) => {
4932
+ const defaultIndent = 12;
4933
+ const baseIndent = 16;
4934
+ const getTreeItemIndent = depth => {
4935
+ return baseIndent + depth * defaultIndent;
4936
+ };
4937
+
4938
+ const getSearchDisplayResultFile = (results, fileIcons, i, setSize, collapsedPaths, text, posInSet, relativeIndex, focused, renderFolderPaths, originalResults) => {
4890
4939
  const path = text;
4891
4940
  const absolutePath = getRelativePath(path);
4892
4941
  const baseName = pathBaseName(path);
4942
+ const relativeFolderPath = getRelativeFolderPath(path);
4943
+ const displayText = renderFolderPaths && relativeFolderPath ? `${baseName} — ${relativeFolderPath}` : baseName;
4893
4944
  const index = originalResults.indexOf(results[i]);
4894
4945
  const matchCount = getMatchCount(originalResults, index);
4895
4946
  const expanded = collapsedPaths.includes(path) ? Collapsed : Expanded;
4896
4947
  const badgeText = `${matchCount}`;
4948
+ const depth = 0;
4949
+ const indent = getTreeItemIndent(depth);
4897
4950
  return {
4898
4951
  badgeText,
4899
- depth: 0,
4952
+ depth,
4900
4953
  expanded,
4901
4954
  focused,
4902
4955
  icon: fileIcons[relativeIndex],
4956
+ indent,
4903
4957
  matchLength: 0,
4904
4958
  matchStart: 0,
4905
4959
  posInSet,
4906
4960
  replacement: '',
4907
4961
  setSize,
4908
- text: baseName,
4962
+ text: displayText,
4909
4963
  title: absolutePath
4910
4964
  };
4911
4965
  };
4912
4966
 
4913
4967
  const getDisplayResultMatch = (setSize, searchTermLength, replacement, text, posInSet, start, focused) => {
4968
+ const depth = 1;
4969
+ const indent = getTreeItemIndent(depth);
4914
4970
  return {
4915
4971
  badgeText: '',
4916
- depth: 1,
4972
+ depth,
4917
4973
  expanded: None,
4918
4974
  focused,
4919
4975
  icon: '',
4976
+ indent,
4920
4977
  matchLength: searchTermLength,
4921
4978
  matchStart: start,
4922
4979
  posInSet,
@@ -4927,7 +4984,7 @@ const getDisplayResultMatch = (setSize, searchTermLength, replacement, text, pos
4927
4984
  };
4928
4985
  };
4929
4986
 
4930
- const getDisplayResult = (results, fileIcons, i, setSize, searchTermLength, replacement, focusedIndex, collapsedPaths, minLineY, originalResults) => {
4987
+ const getDisplayResult = (results, fileIcons, i, setSize, searchTermLength, replacement, focusedIndex, collapsedPaths, renderFolderPaths, minLineY, originalResults) => {
4931
4988
  const result = results[i];
4932
4989
  const {
4933
4990
  start,
@@ -4939,7 +4996,7 @@ const getDisplayResult = (results, fileIcons, i, setSize, searchTermLength, repl
4939
4996
  const relativeIndex = i - minLineY;
4940
4997
  switch (type) {
4941
4998
  case File:
4942
- return getSearchDisplayResultFile(results, fileIcons, i, setSize, collapsedPaths, text, posInSet, relativeIndex, focused, originalResults);
4999
+ return getSearchDisplayResultFile(results, fileIcons, i, setSize, collapsedPaths, text, posInSet, relativeIndex, focused, renderFolderPaths, originalResults);
4943
5000
  case Match:
4944
5001
  return getDisplayResultMatch(setSize, searchTermLength, replacement, text, posInSet, start, focused);
4945
5002
  default:
@@ -4947,14 +5004,14 @@ const getDisplayResult = (results, fileIcons, i, setSize, searchTermLength, repl
4947
5004
  }
4948
5005
  };
4949
5006
 
4950
- const getDisplayResults = (results, itemHeight, resultCount, searchTerm, minLineY, maxLineY, replacement, fileIcons, focusedIndex, collapsedPaths, originalResults) => {
5007
+ const getDisplayResults = (results, itemHeight, resultCount, searchTerm, minLineY, maxLineY, replacement, fileIcons, focusedIndex, collapsedPaths, renderFolderPaths, originalResults) => {
4951
5008
  const filteredResults = getFilteredResults(results, collapsedPaths);
4952
5009
  const displayResults = [];
4953
5010
  const setSize = resultCount;
4954
5011
  const searchTermLength = searchTerm.length;
4955
5012
  const max = Math.min(filteredResults.length, maxLineY);
4956
5013
  for (let i = minLineY; i < max; i++) {
4957
- const displayResult = getDisplayResult(filteredResults, fileIcons, i, setSize, searchTermLength, replacement, focusedIndex, collapsedPaths, minLineY, originalResults);
5014
+ const displayResult = getDisplayResult(filteredResults, fileIcons, i, setSize, searchTermLength, replacement, focusedIndex, collapsedPaths, renderFolderPaths, minLineY, originalResults);
4958
5015
  displayResults.push(displayResult);
4959
5016
  }
4960
5017
  return displayResults;
@@ -4982,12 +5039,13 @@ const createViewModel = state => {
4982
5039
  maxLineY,
4983
5040
  message,
4984
5041
  minLineY,
5042
+ renderFolderPaths,
4985
5043
  replacement,
4986
5044
  scrollBarHeight,
4987
5045
  searchInputErrorMessage,
4988
5046
  value
4989
5047
  } = state;
4990
- const displayResults = getDisplayResults(listItems, itemHeight, fileCount, value, minLineY, maxLineY, replacement, icons, listFocusedIndex, collapsedPaths, items);
5048
+ const displayResults = getDisplayResults(listItems, itemHeight, fileCount, value, minLineY, maxLineY, replacement, icons, listFocusedIndex, collapsedPaths, renderFolderPaths || false, items);
4991
5049
  const focusOutline = listFocused && listFocusedIndex === -1;
4992
5050
  const scrollBarValue = deltaY / finalDeltaY * 100;
4993
5051
  const scrollBarY = getScrollBarY$1(deltaY, finalDeltaY, height - headerHeight, scrollBarHeight);
@@ -5007,6 +5065,118 @@ const createViewModel = state => {
5007
5065
  };
5008
5066
  };
5009
5067
 
5068
+ const getIndentRule = indent => {
5069
+ return `.Indent-${indent} {
5070
+ padding-left: ${indent}px;
5071
+ }`;
5072
+ };
5073
+ const getIndentRightRule = indentRight => {
5074
+ return `.IndentRight-${indentRight} {
5075
+ padding-right: ${indentRight}px;
5076
+ }`;
5077
+ };
5078
+ const getTreeItemsTopRule = treeItemsTop => {
5079
+ const roundedTreeItemsTop = Math.round(treeItemsTop);
5080
+ return `.TreeItemsTop-${roundedTreeItemsTop} {
5081
+ top: ${roundedTreeItemsTop}px;
5082
+ }`;
5083
+ };
5084
+ const getScrollBarThumbTopRule = scrollBarY => {
5085
+ const roundedScrollBarY = Math.round(scrollBarY);
5086
+ return `.ScrollBarThumbTop-${roundedScrollBarY} {
5087
+ transform: translateY(${roundedScrollBarY}px);
5088
+ }`;
5089
+ };
5090
+ const getCss = (top, uniqueIndents, uniqueIndentRights, scrollBarHeight, scrollBarY, treeItemsTop, headerHeight = 0) => {
5091
+ const rules = [`.Search {
5092
+ --ScrollBarHeight: ${scrollBarHeight}px;
5093
+ --ScrollBarTop: ${scrollBarY}px;
5094
+ --TreeItemsTop: ${top}px;
5095
+ }
5096
+
5097
+ .SearchHeader {
5098
+ contain: strict;
5099
+ height: ${headerHeight}px;
5100
+ }
5101
+ `, ...uniqueIndents.map(getIndentRule), ...uniqueIndentRights.map(getIndentRightRule), getTreeItemsTopRule(treeItemsTop), getScrollBarThumbTopRule(scrollBarY)];
5102
+ return rules.join('\n');
5103
+ };
5104
+
5105
+ const getUnique = items => {
5106
+ const seens = [];
5107
+ for (const item of items) {
5108
+ if (!seens.includes(item)) {
5109
+ seens.push(item);
5110
+ }
5111
+ }
5112
+ return seens;
5113
+ };
5114
+
5115
+ const getUniqueIndents = indents => {
5116
+ const uniqueIndents = getUnique(indents);
5117
+ return uniqueIndents;
5118
+ };
5119
+
5120
+ const PaddingRight = 12;
5121
+
5122
+ const renderCss = (oldState, newState) => {
5123
+ const {
5124
+ headerHeight,
5125
+ uid
5126
+ } = newState;
5127
+ const viewModel = createViewModel(newState);
5128
+ const indents = viewModel.displayResults.map(item => item.indent);
5129
+ const uniqueIndents = getUniqueIndents(indents);
5130
+ const uniqueIndentRights = [PaddingRight];
5131
+ const treeItemsTop = viewModel.itemHeight === 0 ? 0 : Math.round(-(viewModel.deltaY % viewModel.itemHeight));
5132
+ const css = getCss(0, uniqueIndents, uniqueIndentRights, viewModel.scrollBarHeight, viewModel.scrollBarY, treeItemsTop, headerHeight);
5133
+ return [SetCss, uid, css];
5134
+ };
5135
+
5136
+ const getFocusSelector = focusKey => {
5137
+ switch (focusKey) {
5138
+ case FocusIgnoreFiles:
5139
+ return UseExcludeSettings;
5140
+ case FocusSearchExcludeInput:
5141
+ return FilesToExclude;
5142
+ case FocusSearchIncludeInput:
5143
+ return FilesToInclude;
5144
+ case FocusSearchInput:
5145
+ return SearchValue;
5146
+ case FocusSearchMatchCase:
5147
+ return MatchCase;
5148
+ case FocusSearchOpenEditors:
5149
+ return SearchOnlyOpenEditors;
5150
+ case FocusSearchPreserveCase:
5151
+ return PreserveCase;
5152
+ case FocusSearchRegex:
5153
+ return UseRegularExpression;
5154
+ case FocusSearchReplaceAll:
5155
+ return ReplaceAll;
5156
+ case FocusSearchReplaceInput:
5157
+ return ReplaceValue;
5158
+ case FocusSearchResults:
5159
+ return '.Tree';
5160
+ case FocusSearchWholeWord:
5161
+ return MatchWholeWord;
5162
+ case FocusToggleDetails:
5163
+ return ToggleSearchDetails;
5164
+ case FocusToggleReplace:
5165
+ return ToggleReplace;
5166
+ default:
5167
+ return '';
5168
+ }
5169
+ };
5170
+
5171
+ const renderFocus = (oldState, newState) => {
5172
+ const selector = getFocusSelector(newState.focus);
5173
+ return [FocusElementByName, newState.uid, selector];
5174
+ };
5175
+
5176
+ const renderFocusContext = (oldState, newState) => {
5177
+ return [SetFocusContext, newState.uid, FocusSearch, newState.focus];
5178
+ };
5179
+
5010
5180
  const HandleClick = 1;
5011
5181
  const HandleListContextMenu = 2;
5012
5182
  const HandleHeaderContextMenu = 3;
@@ -5033,7 +5203,7 @@ const getSearchDetailsToggleVirtualDom = () => {
5033
5203
  return [{
5034
5204
  ariaLabel: toggleSearchDetails(),
5035
5205
  childCount: 1,
5036
- className: ToggleDetails,
5206
+ className: mergeClassNames(ToggleDetails, IconButton),
5037
5207
  name: ToggleSearchDetails,
5038
5208
  onClick: HandleButtonClick,
5039
5209
  role: Button$3,
@@ -5397,6 +5567,7 @@ const getScrollBarVirtualDom = (scrollBarHeight, scrollBarY, scrollBarValue) =>
5397
5567
  if (scrollBarHeight === 0) {
5398
5568
  return [];
5399
5569
  }
5570
+ const roundedScrollBarY = Math.round(scrollBarY);
5400
5571
  return [{
5401
5572
  ariaControls: TreeItems,
5402
5573
  ariaValueNow: scrollBarValue,
@@ -5407,9 +5578,8 @@ const getScrollBarVirtualDom = (scrollBarHeight, scrollBarY, scrollBarValue) =>
5407
5578
  type: Div
5408
5579
  }, {
5409
5580
  childCount: 0,
5410
- className: ScrollBarThumb,
5581
+ className: `${ScrollBarThumb} ScrollBarThumbTop-${roundedScrollBarY}`,
5411
5582
  height: scrollBarHeight,
5412
- translate: `0 ${scrollBarY}px`,
5413
5583
  type: Div
5414
5584
  }];
5415
5585
  };
@@ -5512,17 +5682,14 @@ const getLabelVirtualDom = (displayText, matchLength, matchStart, replacement) =
5512
5682
  const highlight = displayText.slice(matchStart, matchStart + matchLength);
5513
5683
  const after = displayText.slice(matchStart + matchLength);
5514
5684
  if (replacement) {
5515
- return [label4, text(before), deleted, text(highlight), inserted, text(replacement), text(after)];
5685
+ const replacementPreview = replacement.split(/\r\n|\r|\n/, 1)[0];
5686
+ return [label4, text(before), deleted, text(highlight), inserted, text(replacementPreview), text(after)];
5516
5687
  }
5517
5688
  return [label3, text(before), highlighted, text(highlight), text(after)];
5518
5689
  }
5519
5690
  return [label1, text(displayText)];
5520
5691
  };
5521
5692
 
5522
- const getPaddingLeft = depth => {
5523
- return `${Number(depth) + 1}rem`; // TODO use classname and dynamic css
5524
- };
5525
-
5526
5693
  const getChildCount = (icon, expanded, badgeText) => {
5527
5694
  let childCount = 0;
5528
5695
  if (expanded) {
@@ -5563,8 +5730,6 @@ const getSearchResultClassName = focused => {
5563
5730
  return TreeItem;
5564
5731
  };
5565
5732
 
5566
- const PaddingRight = '12px';
5567
-
5568
5733
  const getSearchResultVirtualDom = rowInfo => {
5569
5734
  const {
5570
5735
  badgeText,
@@ -5572,6 +5737,7 @@ const getSearchResultVirtualDom = rowInfo => {
5572
5737
  expanded,
5573
5738
  focused,
5574
5739
  icon,
5740
+ indent,
5575
5741
  matchLength,
5576
5742
  matchStart,
5577
5743
  posInSet,
@@ -5580,6 +5746,7 @@ const getSearchResultVirtualDom = rowInfo => {
5580
5746
  text: displayText,
5581
5747
  title
5582
5748
  } = rowInfo;
5749
+ const className = `${getSearchResultClassName(focused)} Indent-${indent} IndentRight-${PaddingRight}`;
5583
5750
  const childCount = getChildCount(icon, expanded, badgeText);
5584
5751
  const dom = [{
5585
5752
  ariaDescription: '',
@@ -5589,9 +5756,7 @@ const getSearchResultVirtualDom = rowInfo => {
5589
5756
  ariaPosInSet: posInSet,
5590
5757
  ariaSetSize: setSize,
5591
5758
  childCount,
5592
- className: getSearchResultClassName(focused),
5593
- paddingLeft: getPaddingLeft(depth),
5594
- paddingRight: PaddingRight,
5759
+ className,
5595
5760
  role: TreeItem$1,
5596
5761
  title,
5597
5762
  type: Div
@@ -5600,17 +5765,16 @@ const getSearchResultVirtualDom = rowInfo => {
5600
5765
  };
5601
5766
 
5602
5767
  const getTreeItemsVirtualDom = (visibleItems, deltaY, itemHeight) => {
5603
- const pixelOffset = deltaY % itemHeight;
5768
+ const pixelOffset = itemHeight === 0 ? 0 : deltaY % itemHeight;
5769
+ const treeItemsTop = Math.round(-pixelOffset);
5604
5770
  return [{
5605
5771
  childCount: visibleItems.length,
5606
- className: TreeItems$1,
5772
+ className: `${TreeItems$1} TreeItemsTop-${treeItemsTop}`,
5607
5773
  id: TreeItems,
5608
5774
  onBlur: HandleListBlur,
5609
5775
  onClick: HandleClick,
5610
5776
  onContextMenu: HandleListContextMenu,
5611
5777
  onWheel: HandleWheel,
5612
- top: `${-pixelOffset}px`,
5613
- // TODO use dynamic css instead
5614
5778
  type: Div
5615
5779
  }, ...visibleItems.flatMap(getSearchResultVirtualDom)];
5616
5780
  };
@@ -5644,18 +5808,18 @@ const getSearchVirtualDom = (visibleItems, flags, message, focusOutline, searchI
5644
5808
  }, ...getSearchHeaderVirtualDom(flags, message, searchInputErrorMessage, matchCount, focus, limitHitWarning), ...errorDom, ...getSearchResultsVirtualDom(visibleItems, focusOutline, scrollBarHeight, scrollBarY, scrollBarValue, deltaY, itemHeight)];
5645
5809
  };
5646
5810
 
5647
- const renderItems = (oldState, newState) => {
5811
+ const getDom = newState => {
5648
5812
  const viewModel = createViewModel(newState);
5649
5813
  const dom = getSearchVirtualDom(viewModel.displayResults, viewModel.flags, viewModel.message, viewModel.focusOutline, viewModel.searchInputErrorMessage, viewModel.scrollBarHeight, viewModel.scrollBarY, viewModel.scrollBarValue, viewModel.deltaY, viewModel.itemHeight, viewModel.matchCount, newState.limitHitWarning, viewModel.focus, newState.initial);
5650
- return [SetDom2, newState.uid, dom];
5814
+ return dom;
5651
5815
  };
5652
5816
 
5653
5817
  // TODO cache rendered dom so that it can be used for dom diffing
5654
5818
  const renderIncremental = (oldState, newState) => {
5655
- const oldDom = renderItems(oldState, oldState)[2];
5656
- const newDom = renderItems(newState, newState)[2];
5819
+ const oldDom = getDom(oldState);
5820
+ const newDom = getDom(newState);
5657
5821
  const patches = diffTree(oldDom, newDom);
5658
- return ['Viewlet.setPatches', newState.uid, patches];
5822
+ return [SetPatches, newState.uid, patches];
5659
5823
  };
5660
5824
 
5661
5825
  const renderSelections = (oldState, newState) => {
@@ -5680,6 +5844,8 @@ const renderExcludeValue = (oldState, newState) => {
5680
5844
 
5681
5845
  const getRenderer = diffType => {
5682
5846
  switch (diffType) {
5847
+ case RenderCss:
5848
+ return renderCss;
5683
5849
  case RenderExcludeValue:
5684
5850
  return renderExcludeValue;
5685
5851
  case RenderFocus:
@@ -5690,8 +5856,6 @@ const getRenderer = diffType => {
5690
5856
  return renderIncludeValue;
5691
5857
  case RenderIncremental:
5692
5858
  return renderIncremental;
5693
- case RenderItems:
5694
- return renderItems;
5695
5859
  case RenderReplaceValue:
5696
5860
  return renderReplacement;
5697
5861
  case RenderSelections:
@@ -6135,7 +6299,9 @@ const commandMap = {
6135
6299
  'TextSearch.copyPath': wrapCommand(copyPath$1),
6136
6300
  'TextSearch.create': create,
6137
6301
  'TextSearch.diff2': diff2,
6302
+ 'TextSearch.disableRenderFolderPaths': wrapCommand(disableRenderFolderPaths),
6138
6303
  'TextSearch.dismissItem': wrapCommand(dismissItem),
6304
+ 'TextSearch.enableRenderFolderPaths': wrapCommand(enableRenderFolderPaths),
6139
6305
  'TextSearch.expandDetails': wrapCommand(expandDetails),
6140
6306
  'TextSearch.focusFirst': wrapCommand(focusFirst),
6141
6307
  'TextSearch.focusIndex': wrapCommand(focusIndex),
@@ -6189,11 +6355,13 @@ const commandMap = {
6189
6355
  'TextSearch.handleListPointerDown': wrapCommand(handleListPointerDown),
6190
6356
  'TextSearch.handlePullResultsFound': wrapCommand(handlePullResultsFound),
6191
6357
  'TextSearch.handleReplaceInput': wrapCommand(handleReplaceInput),
6358
+ 'TextSearch.handleResize': wrapCommand(handleResize),
6192
6359
  'TextSearch.handleScrollBarCaptureLost': wrapCommand(handleScrollBarCaptureLost),
6193
6360
  'TextSearch.handleScrollBarClick': wrapCommand(handleScrollBarClick),
6194
6361
  'TextSearch.handleScrollBarMove': wrapCommand(handleScrollBarMove),
6195
6362
  'TextSearch.handleSharedInput': wrapCommand(handleSharedInput),
6196
6363
  'TextSearch.handleWheel': wrapCommand(handleWheel),
6364
+ 'TextSearch.handleWorkspaceChange': wrapCommand(handleWorkspaceChange),
6197
6365
  // not wrapped
6198
6366
  'TextSearch.initialize': initialize,
6199
6367
  'TextSearch.loadContent': wrapCommand(loadContent),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/text-search-worker",
3
- "version": "6.2.0",
3
+ "version": "6.4.0",
4
4
  "description": "Text Search Worker",
5
5
  "keywords": [
6
6
  "text-search"