@lvce-editor/text-search-worker 4.3.0 → 4.5.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.
@@ -1242,7 +1242,8 @@ const create = (uid, x, y, width, height, workspacePath, assetDir, itemHeight, v
1242
1242
  flags: 0,
1243
1243
  platform,
1244
1244
  searchInputErrorMessage: '',
1245
- history: []
1245
+ history: [],
1246
+ historyIndex: -1
1246
1247
  };
1247
1248
  set(uid, state, state);
1248
1249
  return state;
@@ -1254,6 +1255,7 @@ const RenderValue = 3;
1254
1255
  const RenderReplaceValue = 4;
1255
1256
  const RenderIncludeValue = 5;
1256
1257
  const RenderExcludeValue = 6;
1258
+ const RenderFocusContext = 7;
1257
1259
 
1258
1260
  const diffType$5 = RenderExcludeValue;
1259
1261
  const isEqual$5 = (oldState, newState) => {
@@ -1272,7 +1274,7 @@ const isEqual$3 = (oldState, newState) => {
1272
1274
 
1273
1275
  const diffType$2 = RenderItems;
1274
1276
  const isEqual$2 = (oldState, newState) => {
1275
- return oldState.items === newState.items && oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY && oldState.replacement === newState.replacement && oldState.flags === newState.flags && oldState.message === newState.message && oldState.loaded === newState.loaded && oldState.collapsedPaths === newState.collapsedPaths && oldState.listFocusedIndex === newState.listFocusedIndex && oldState.listFocused === newState.listFocused && oldState.icons === newState.icons && oldState.searchInputErrorMessage === newState.searchInputErrorMessage && oldState.deltaY === newState.deltaY;
1277
+ 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;
1276
1278
  };
1277
1279
 
1278
1280
  const diffType$1 = RenderReplaceValue;
@@ -1332,6 +1334,8 @@ const ConfirmReplaceManyOccurrencesInOneFile = "Replace {PH1} occurrences across
1332
1334
  const ConfirmReplaceManyOccurrencesInOneFileNoValue = 'Replace {PH1} occurrences across 1 file';
1333
1335
  const ConfirmReplaceOneOccurrenceInOneFile = "Replace 1 occurrence across 1 file with '{PH1}'";
1334
1336
  const ConfirmReplaceOneOccurrenceInOneFileNoValue = 'Replace 1 occurrence across 1 file';
1337
+ const FilesToExclude$1 = 'Files to Exclude';
1338
+ const FilesToInclude$1 = 'Files to Include';
1335
1339
  const ManyResultsInManyFiles = '{PH1} results in {PH2} files';
1336
1340
  const ManyResultsInOneFile = '{PH1} results in 1 file';
1337
1341
  const MatchCase$1 = 'Match Case';
@@ -1343,13 +1347,14 @@ const Replace = 'Replace';
1343
1347
  const ReplaceAll$1 = 'Replace All';
1344
1348
  const ReplacedManyOccurrencesInManyFiles = "Replaced {PH1} occurrences across {PH2} files with '{PH3}'";
1345
1349
  const ReplacedOneOccurrenceInOneFile = "Replaced 1 occurrence across 1 file with '{PH1}'";
1350
+ const Search$2 = 'Search';
1351
+ const SearchForHistory = 'Search (⇅ for history)';
1352
+ const ReplaceForHistory = 'Replace (⇅ for history)';
1353
+ const SearchOnlyOpenEditors$1 = 'Search Only Open Editors';
1346
1354
  const ToggleReplace$1 = 'Toggle Replace';
1347
- const UseRegularExpression$1 = 'Use Regular Expression';
1348
- const FilesToInclude$1 = 'Files to Include';
1349
- const FilesToExclude$1 = 'Files to Exclude';
1350
1355
  const ToggleSearchDetails$1 = 'Toggle Search Details';
1351
- const SearchOnlyOpenEditors$1 = 'Search Only Open Editors';
1352
1356
  const UseExcludeSettings$1 = 'Use Exclude Settings';
1357
+ const UseRegularExpression$1 = 'Use Regular Expression';
1353
1358
 
1354
1359
  const noResults = () => {
1355
1360
  return i18nString(NoResults);
@@ -1454,6 +1459,15 @@ const searchOnlyOpenEditors = () => {
1454
1459
  const useExcludeSettings = () => {
1455
1460
  return i18nString(UseExcludeSettings$1);
1456
1461
  };
1462
+ const searchForHistory = () => {
1463
+ return i18nString(SearchForHistory);
1464
+ };
1465
+ const search = () => {
1466
+ return i18nString(Search$2);
1467
+ };
1468
+ const replaceForHistory = () => {
1469
+ return i18nString(ReplaceForHistory);
1470
+ };
1457
1471
 
1458
1472
  const getStatusMessage = (resultCount, fileResultCount) => {
1459
1473
  if (resultCount === 0) {
@@ -1717,7 +1731,12 @@ const focusReplaceValue$1 = state => {
1717
1731
  };
1718
1732
  };
1719
1733
 
1720
- const focusSearchValue$1 = state => {
1734
+ const setFocus = async focusKey => {
1735
+ await invoke$2('Focus.setFocus', focusKey);
1736
+ };
1737
+
1738
+ const focusSearchValue$1 = async state => {
1739
+ await setFocus(FocusSearchInput);
1721
1740
  return {
1722
1741
  ...state,
1723
1742
  focus: FocusSearchInput
@@ -1731,7 +1750,7 @@ const focusSearchValueNext = state => {
1731
1750
  return focusMatchCase$1(state);
1732
1751
  };
1733
1752
 
1734
- const commandIds = ['clearSearchResults', 'collapseDetails', 'copy', 'dismissItem', 'expandDetails', 'focusFirst', 'focusIndex', 'focusLast', 'focusMatchCase', 'focusMatchCasePrevious', 'focusMatchWholeWord', 'focusNext', 'focusNextInput', 'focusNextPage', 'focusPreserveCasePrevious', 'focusPrevious', 'focusPreviousInput', 'focusPreviousPage', 'focusRegex', 'focusRegexNext', 'focusReplaceAll', 'focusReplaceValue', 'focusReplaceValueNext', 'focusReplaceValuePrevious', 'focusSearchValue', 'focusSearchValueNext', 'handleClick', 'handleClickAt', 'handleContextMenu', 'handleContextMenuKeyboard', 'handleContextMenuMouseAt', 'handleExcludeInput', 'handleFocusIn', 'handleHeaderClick', 'handleHeaderFocusIn', 'handleIconThemeChange', 'handleIconThemeChange', 'handleIncludeInput', 'handleInput', 'handleInput2', 'handleListBlur', 'handleListFocus', 'handleReplaceInput', 'handleScrollBarCaptureLost', 'handleScrollBarClick', 'handleScrollBarMove', 'handleScrollBarThumbPointerMove', 'handleTouchEnd', 'handleTouchMove', 'handleTouchStart', 'handleUpdate', 'handleWheel', 'nextHistoryResult', 'previousHistoryResult', 'refresh', 'replaceAll', 'scrollDown', 'selectIndex', 'submit', 'toggleMatchCase', 'toggleMatchWholeWord', 'togglePreserveCase', 'toggleReplace', 'toggleSearchDetails', 'toggleUseRegularExpression'];
1753
+ const commandIds = ['clearSearchResults', 'collapseDetails', 'copy', 'dismissItem', 'expandDetails', 'focusFirst', 'focusIndex', 'focusLast', 'focusMatchCase', 'focusMatchCasePrevious', 'focusMatchWholeWord', 'focusNext', 'focusNextInput', 'focusNextPage', 'focusPreserveCasePrevious', 'focusPrevious', 'focusPreviousInput', 'focusPreviousPage', 'focusRegex', 'focusRegexNext', 'focusReplaceAll', 'focusReplaceValue', 'focusReplaceValueNext', 'focusReplaceValuePrevious', 'focusSearchValue', 'focusSearchValueNext', 'handleClick', 'handleClickAt', 'handleContextMenu', 'handleContextMenuKeyboard', 'handleContextMenuMouseAt', 'handleExcludeInput', 'handleFocusIn', 'handleHeaderClick', 'handleHeaderFocusIn', 'handleHeaderFocusOut', 'handleIconThemeChange', 'handleIconThemeChange', 'handleIncludeInput', 'handleInput', 'handleInput2', 'handleListBlur', 'handleListFocus', 'handleReplaceInput', 'handleScrollBarCaptureLost', 'handleScrollBarClick', 'handleScrollBarMove', 'handleScrollBarThumbPointerMove', 'handleTouchEnd', 'handleTouchMove', 'handleTouchStart', 'handleUpdate', 'handleWheel', 'nextHistoryResult', 'previousHistoryResult', 'refresh', 'replaceAll', 'scrollDown', 'selectIndex', 'submit', 'toggleMatchCase', 'toggleMatchWholeWord', 'togglePreserveCase', 'toggleReplace', 'toggleSearchDetails', 'toggleUseRegularExpression'];
1735
1754
 
1736
1755
  const getCommandIds = () => {
1737
1756
  return commandIds;
@@ -1766,11 +1785,11 @@ const getKeyBindings = () => {
1766
1785
  }, {
1767
1786
  key: UpArrow,
1768
1787
  command: 'Search.previousHistoryResult',
1769
- when: FocusSearch
1788
+ when: FocusSearchInput
1770
1789
  }, {
1771
1790
  key: DownArrow,
1772
1791
  command: 'Search.nextHistoryResult',
1773
- when: FocusSearch
1792
+ when: FocusSearchInput
1774
1793
  }, {
1775
1794
  key: DownArrow,
1776
1795
  command: 'Search.focusNext',
@@ -2370,6 +2389,10 @@ const getClickHandler = name => {
2370
2389
  return toggleOpenEditors;
2371
2390
  case UseExcludeSettings:
2372
2391
  return toggleUseIgnoreFiles;
2392
+ case SearchValue:
2393
+ return focusSearchValue$1;
2394
+ case ReplaceValue:
2395
+ return focusReplaceValue$1;
2373
2396
  default:
2374
2397
  return noop;
2375
2398
  }
@@ -2384,6 +2407,17 @@ const handleHeaderFocusIn = state => {
2384
2407
  return state;
2385
2408
  };
2386
2409
 
2410
+ const handleHeaderFocusOut = state => {
2411
+ if (!state.focus) {
2412
+ return state;
2413
+ }
2414
+ return {
2415
+ ...state,
2416
+ focused: false,
2417
+ focus: 0
2418
+ };
2419
+ };
2420
+
2387
2421
  const handleIconThemeChange = async state => {
2388
2422
  const {
2389
2423
  items,
@@ -2719,7 +2753,7 @@ const handleWheel = (state, deltaMode, deltaY) => {
2719
2753
  const getListIndex = (eventX, eventY, x, y, deltaY, itemHeight, topHeight, itemCount) => {
2720
2754
  const relativeY = eventY - y - topHeight + deltaY;
2721
2755
  const index = Math.floor(relativeY / itemHeight);
2722
- if (index >= itemCount) {
2756
+ if (index < 0 || index >= itemCount) {
2723
2757
  return -1;
2724
2758
  }
2725
2759
  return index;
@@ -2882,6 +2916,16 @@ const handleClickAt = (state, eventX, eventY) => {
2882
2916
  return selectIndex(state, index);
2883
2917
  };
2884
2918
 
2919
+ const isString = value => {
2920
+ return typeof value === 'string';
2921
+ };
2922
+ const getSavedHistory = savedState => {
2923
+ if (savedState && typeof savedState === 'object' && 'history' in savedState && Array.isArray(savedState.history) && savedState.history.every(isString)) {
2924
+ return savedState.history;
2925
+ }
2926
+ return [];
2927
+ };
2928
+
2885
2929
  const getSavedValue = savedState => {
2886
2930
  if (savedState && typeof savedState === 'object' && 'value' in savedState && typeof savedState.value === 'string') {
2887
2931
  return savedState.value;
@@ -2921,7 +2965,8 @@ const restoreState = savedState => {
2921
2965
  threads: 1,
2922
2966
  flags: getSavedFlags(savedState),
2923
2967
  includeValue: getSavedIncludeValue(savedState),
2924
- excludeValue: getSavedExcludeValue(savedState)
2968
+ excludeValue: getSavedExcludeValue(savedState),
2969
+ history: getSavedHistory(savedState)
2925
2970
  };
2926
2971
  };
2927
2972
 
@@ -2955,12 +3000,40 @@ const loadContent = async (state, savedState) => {
2955
3000
  };
2956
3001
  };
2957
3002
 
2958
- const nextHistoryResult = async state => {
3003
+ const getNextHistoryData = (history, historyIndex) => {
3004
+ if (historyIndex === -1 || history.length === 0) {
3005
+ return {
3006
+ newValue: '',
3007
+ newHistoryIndex: -1
3008
+ };
3009
+ }
3010
+ const item = history.at(historyIndex) || '';
2959
3011
  return {
2960
- ...state
3012
+ newValue: item,
3013
+ newHistoryIndex: historyIndex + 1
2961
3014
  };
2962
3015
  };
2963
3016
 
3017
+ const nextHistoryResult = async state => {
3018
+ const {
3019
+ history,
3020
+ historyIndex,
3021
+ value
3022
+ } = state;
3023
+ const {
3024
+ newValue,
3025
+ newHistoryIndex
3026
+ } = getNextHistoryData(history, historyIndex);
3027
+ if (newValue === value) {
3028
+ return state;
3029
+ }
3030
+ return handleUpdate(state, {
3031
+ value: newValue,
3032
+ inputSource: Script,
3033
+ historyIndex: newHistoryIndex
3034
+ });
3035
+ };
3036
+
2964
3037
  const previousHistoryResult = async state => {
2965
3038
  return {
2966
3039
  ...state
@@ -3009,6 +3082,10 @@ const renderFocus = (oldState, newState) => {
3009
3082
  return ['Viewlet.focusElementByName', newState.uid, selector];
3010
3083
  };
3011
3084
 
3085
+ const renderFocusContext = (oldState, newState) => {
3086
+ return ['Viewlet.setFocusContext', newState.focus];
3087
+ };
3088
+
3012
3089
  const None$1 = 0;
3013
3090
  const Collapsed = 1;
3014
3091
  const Expanded = 2;
@@ -3132,7 +3209,8 @@ const createViewModel = state => {
3132
3209
  message,
3133
3210
  searchInputErrorMessage,
3134
3211
  scrollBarHeight,
3135
- matchCount
3212
+ matchCount,
3213
+ focus
3136
3214
  } = state;
3137
3215
  const displayResults = getDisplayResults(listItems, itemHeight, fileCount, value, minLineY, maxLineY, replacement, icons, listFocusedIndex, collapsedPaths, items);
3138
3216
  const focusOutline = listFocused && listFocusedIndex === -1;
@@ -3149,7 +3227,8 @@ const createViewModel = state => {
3149
3227
  scrollBarValue,
3150
3228
  deltaY,
3151
3229
  itemHeight,
3152
- matchCount
3230
+ matchCount,
3231
+ focus
3153
3232
  };
3154
3233
  };
3155
3234
 
@@ -3222,19 +3301,20 @@ const Tree = 'tree';
3222
3301
  const TreeItem = 'treeitem';
3223
3302
 
3224
3303
  const HandleClick = 'handleClick';
3304
+ const HandleContextMenu = 'handleContextMenu';
3225
3305
  const HandleExcludeInput = 'handleExcludeInput';
3226
3306
  const HandleHeaderClick2 = 'handleHeaderClick2';
3227
3307
  const HandleHeaderFocusIn = 'handleHeaderFocusIn';
3308
+ const HandleHeaderFocusOut = 'handleHeaderFocusOut';
3228
3309
  const HandleIncludeInput = 'handleIncludeInput';
3229
3310
  const HandleInput = 'handleInput';
3230
3311
  const HandleInput2 = 'handleInput2';
3231
3312
  const HandleListBlur = 'handleListBlur';
3313
+ const HandleListFocus = 'handleListFocus';
3232
3314
  const HandleReplaceInput = 'handleReplaceInput';
3233
3315
  const HandleScrollBarPointerDown = 'handleScrollBarPointerDown';
3234
3316
  const HandleToggleButtonClick = 'handleToggleButtonClick';
3235
3317
  const HandleWheel = 'handleWheel';
3236
- const HandleListFocus = 'handleListFocus';
3237
- const HandleContextMenu = 'handleContextMenu';
3238
3318
 
3239
3319
  const mergeClassNames = (...classNames) => {
3240
3320
  return classNames.filter(Boolean).join(' ');
@@ -3726,6 +3806,20 @@ const getInputActionsReplace = (flags, matchCount) => {
3726
3806
  };
3727
3807
  };
3728
3808
 
3809
+ const getReplacePlaceholder = focus => {
3810
+ if (focus === FocusSearchReplaceInput) {
3811
+ return replaceForHistory();
3812
+ }
3813
+ return replace();
3814
+ };
3815
+
3816
+ const getSearchPlaceholder = focus => {
3817
+ if (focus === FocusSearchInput) {
3818
+ return searchForHistory();
3819
+ }
3820
+ return search();
3821
+ };
3822
+
3729
3823
  const getSearchToggleVirtualDom = flags => {
3730
3824
  return [{
3731
3825
  type: Button$1,
@@ -3743,9 +3837,11 @@ const getSearchToggleVirtualDom = flags => {
3743
3837
  }];
3744
3838
  };
3745
3839
 
3746
- const getSearchHeaderTopVirtualDom = (flags, searchInputErrorMessage, matchCount) => {
3840
+ const getSearchHeaderTopVirtualDom = (flags, searchInputErrorMessage, matchCount, focus) => {
3747
3841
  const inputActions = getInputActionsInput(flags);
3748
3842
  const replaceActions = getInputActionsReplace(flags, matchCount);
3843
+ const searchPlaceholder = getSearchPlaceholder(focus);
3844
+ const replacePlaceholder = getReplacePlaceholder(focus);
3749
3845
  const dom = [{
3750
3846
  type: Div,
3751
3847
  className: SearchHeaderTop,
@@ -3756,9 +3852,9 @@ const getSearchHeaderTopVirtualDom = (flags, searchInputErrorMessage, matchCount
3756
3852
  className: SearchHeaderTopRight,
3757
3853
  role: None,
3758
3854
  childCount: flags & ReplaceExpanded ? 2 : 1
3759
- }, ...getSearchFieldVirtualDom(SearchValue, 'Search', HandleInput2, inputActions.inside, inputActions.outside, '', Boolean(searchInputErrorMessage))];
3855
+ }, ...getSearchFieldVirtualDom(SearchValue, searchPlaceholder, HandleInput2, inputActions.inside, inputActions.outside, '', Boolean(searchInputErrorMessage))];
3760
3856
  if (flags & ReplaceExpanded) {
3761
- dom.push(...getSearchFieldVirtualDom(ReplaceValue, 'Replace', HandleInput2, replaceActions.inside, replaceActions.outside));
3857
+ dom.push(...getSearchFieldVirtualDom(ReplaceValue, replacePlaceholder, HandleInput2, replaceActions.inside, replaceActions.outside));
3762
3858
  }
3763
3859
  return dom;
3764
3860
  };
@@ -3769,10 +3865,11 @@ const parentNode = {
3769
3865
  role: None,
3770
3866
  childCount: 2,
3771
3867
  onClick: HandleHeaderClick2,
3772
- onFocusIn: HandleHeaderFocusIn
3868
+ onFocusIn: HandleHeaderFocusIn,
3869
+ onFocusOut: HandleHeaderFocusOut
3773
3870
  };
3774
- const getSearchHeaderVirtualDom = (flags, message, searchInputErrorMessage, matchCount) => {
3775
- const dom = [parentNode, ...getSearchHeaderTopVirtualDom(flags, searchInputErrorMessage, matchCount), ...getSearchHeaderDetailsVirtualDom(flags, message)];
3871
+ const getSearchHeaderVirtualDom = (flags, message, searchInputErrorMessage, matchCount, focus) => {
3872
+ const dom = [parentNode, ...getSearchHeaderTopVirtualDom(flags, searchInputErrorMessage, matchCount, focus), ...getSearchHeaderDetailsVirtualDom(flags, message)];
3776
3873
  return dom;
3777
3874
  };
3778
3875
 
@@ -3988,33 +4085,33 @@ const getSearchResultsVirtualDom = (visibleItems, focusOutline, scrollbarHeight,
3988
4085
  }, ...getTreeItemsVirtualDom(visibleItems, deltaY, itemHeight), ...getScrollBarVirtualDom(scrollbarHeight, scrollBarY, scrollBarValue)];
3989
4086
  };
3990
4087
 
3991
- const getSearchVirtualDom = (visibleItems, flags, message, focusOutline, searchInputErrorMessage, scrollBarHeight, scrollBarY, scrollBarValue, deltaY, itemHeight, matchCount) => {
4088
+ const getSearchVirtualDom = (visibleItems, flags, message, focusOutline, searchInputErrorMessage, scrollBarHeight, scrollBarY, scrollBarValue, deltaY, itemHeight, matchCount, focus = 0) => {
3992
4089
  const errorDom = getSearchInputErrorVirtualDom(searchInputErrorMessage);
3993
4090
  const childCount = 2 + (errorDom.length > 0 ? 1 : 0);
3994
4091
  return [{
3995
4092
  type: Div,
3996
4093
  className: mergeClassNames(Viewlet, Search$1),
3997
4094
  childCount
3998
- }, ...getSearchHeaderVirtualDom(flags, message, searchInputErrorMessage, matchCount), ...errorDom, ...getSearchResultsVirtualDom(visibleItems, focusOutline, scrollBarHeight, scrollBarY, scrollBarValue, deltaY, itemHeight)];
4095
+ }, ...getSearchHeaderVirtualDom(flags, message, searchInputErrorMessage, matchCount, focus), ...errorDom, ...getSearchResultsVirtualDom(visibleItems, focusOutline, scrollBarHeight, scrollBarY, scrollBarValue, deltaY, itemHeight)];
3999
4096
  };
4000
4097
 
4001
4098
  const renderItems = (oldState, newState) => {
4002
4099
  const viewModel = createViewModel(newState);
4003
- 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);
4100
+ 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, viewModel.focus);
4004
4101
  return ['Viewlet.setDom2', newState.uid, dom];
4005
4102
  };
4006
4103
 
4007
4104
  const renderValue = (oldState, newState) => {
4008
- return ['Viewlet.send', newState.uid, 'setValue', newState.value, `[name="${SearchValue}"]`];
4105
+ return ['Viewlet.setValueByName', SearchValue, newState.value];
4009
4106
  };
4010
4107
  const renderReplacement = (oldState, newState) => {
4011
- return ['Viewlet.send', newState.uid, 'setValue', newState.replacement, `[name=${ReplaceValue}]`];
4108
+ return ['Viewlet.setValueByName', ReplaceValue, newState.replacement];
4012
4109
  };
4013
4110
  const renderIncludeValue = (oldState, newState) => {
4014
- return ['Viewlet.send', newState.uid, 'setValue', newState.includeValue, `[name=${FilesToInclude}]`];
4111
+ return ['Viewlet.setValueByName', FilesToInclude, newState.includeValue];
4015
4112
  };
4016
4113
  const renderExcludeValue = (oldState, newState) => {
4017
- return ['Viewlet.send', newState.uid, 'setValue', newState.excludeValue, `[name=${FilesToExclude}]`];
4114
+ return ['Viewlet.setValueByName', FilesToExclude, newState.excludeValue];
4018
4115
  };
4019
4116
 
4020
4117
  const getRenderer = diffType => {
@@ -4031,6 +4128,8 @@ const getRenderer = diffType => {
4031
4128
  return renderExcludeValue;
4032
4129
  case RenderItems:
4033
4130
  return renderItems;
4131
+ case RenderFocusContext:
4132
+ return renderFocusContext;
4034
4133
  default:
4035
4134
  throw new Error('unknown renderer');
4036
4135
  }
@@ -4154,6 +4253,9 @@ const renderEventListeners = () => {
4154
4253
  }, {
4155
4254
  name: HandleHeaderFocusIn,
4156
4255
  params: ['handleHeaderFocusIn']
4256
+ }, {
4257
+ name: HandleHeaderFocusOut,
4258
+ params: ['handleHeaderFocusOut']
4157
4259
  }, {
4158
4260
  name: HandleScrollBarPointerDown,
4159
4261
  params: ['handleScrollBarClick', 'event.deltaY']
@@ -4165,7 +4267,7 @@ const getDom = state => {
4165
4267
  const focusOutline = state.listFocused && state.listFocusedIndex === -1;
4166
4268
  const scrollBarValue = state.deltaY / state.finalDeltaY * 100;
4167
4269
  const scrollBarY = getScrollBarY$1(state.deltaY, state.finalDeltaY, state.height - state.headerHeight, state.scrollBarHeight);
4168
- const dom = getSearchVirtualDom(displayResults, state.flags, state.message, focusOutline, state.searchInputErrorMessage, state.scrollBarHeight, scrollBarY, scrollBarValue, state.deltaY, state.itemHeight, state.matchCount);
4270
+ const dom = getSearchVirtualDom(displayResults, state.flags, state.message, focusOutline, state.searchInputErrorMessage, state.scrollBarHeight, scrollBarY, scrollBarValue, state.deltaY, state.itemHeight, state.matchCount, state.focus);
4169
4271
  return dom;
4170
4272
  };
4171
4273
 
@@ -4255,10 +4357,6 @@ const focusElement = (state, focusKey) => {
4255
4357
  };
4256
4358
  };
4257
4359
 
4258
- const setFocus = async focusKey => {
4259
- await invoke$2('Focus.setFocus', focusKey);
4260
- };
4261
-
4262
4360
  const getSearchFocusKey = key => {
4263
4361
  switch (key) {
4264
4362
  case SearchValue:
@@ -4292,12 +4390,12 @@ const getSearchFocusKey = key => {
4292
4390
  }
4293
4391
  };
4294
4392
 
4295
- const handleFocusIn = (state, key) => {
4393
+ const handleFocusIn = async (state, key) => {
4296
4394
  const focusKey = getSearchFocusKey(key);
4297
4395
  if (state.focus === focusKey) {
4298
4396
  return state;
4299
4397
  }
4300
- void setFocus(FocusSearch);
4398
+ await setFocus(FocusSearch);
4301
4399
  return {
4302
4400
  ...state,
4303
4401
  focus: focusKey,
@@ -4345,10 +4443,18 @@ const focusReplaceAll = state => {
4345
4443
  return focusElement(state, FocusSearchReplaceAll);
4346
4444
  };
4347
4445
 
4446
+ const getNewHistory = (history, newValue) => {
4447
+ const newHistory = [...history, newValue];
4448
+ const maxHistoryLength = 100;
4449
+ const cutHistory = newHistory.slice(0, maxHistoryLength);
4450
+ return cutHistory;
4451
+ };
4348
4452
  const submit = state => {
4453
+ const newHistory = getNewHistory(state.history, state.value);
4349
4454
  return handleUpdate(state, {
4350
4455
  value: state.value,
4351
- inputSource: User
4456
+ inputSource: User,
4457
+ history: newHistory
4352
4458
  });
4353
4459
  };
4354
4460
 
@@ -4451,6 +4557,7 @@ const commandMap = {
4451
4557
  'TextSearch.handleFocusIn': wrapCommand(handleFocusIn),
4452
4558
  'TextSearch.handleHeaderClick': wrapCommand(handleHeaderClick),
4453
4559
  'TextSearch.handleHeaderFocusIn': wrapCommand(handleHeaderFocusIn),
4560
+ 'TextSearch.handleHeaderFocusOut': wrapCommand(handleHeaderFocusOut),
4454
4561
  'TextSearch.handleIconThemeChange': wrapCommand(handleIconThemeChange),
4455
4562
  'TextSearch.handleIncludeInput': wrapCommand(handleIncludeInput),
4456
4563
  'TextSearch.handleInput': wrapCommand(handleInput),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/text-search-worker",
3
- "version": "4.3.0",
3
+ "version": "4.5.0",
4
4
  "description": "Text Search Worker",
5
5
  "keywords": [
6
6
  "text-search"