@lvce-editor/text-search-worker 4.3.0 → 4.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.
@@ -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;
@@ -1272,7 +1273,7 @@ const isEqual$3 = (oldState, newState) => {
1272
1273
 
1273
1274
  const diffType$2 = RenderItems;
1274
1275
  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;
1276
+ 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
1277
  };
1277
1278
 
1278
1279
  const diffType$1 = RenderReplaceValue;
@@ -1332,6 +1333,8 @@ const ConfirmReplaceManyOccurrencesInOneFile = "Replace {PH1} occurrences across
1332
1333
  const ConfirmReplaceManyOccurrencesInOneFileNoValue = 'Replace {PH1} occurrences across 1 file';
1333
1334
  const ConfirmReplaceOneOccurrenceInOneFile = "Replace 1 occurrence across 1 file with '{PH1}'";
1334
1335
  const ConfirmReplaceOneOccurrenceInOneFileNoValue = 'Replace 1 occurrence across 1 file';
1336
+ const FilesToExclude$1 = 'Files to Exclude';
1337
+ const FilesToInclude$1 = 'Files to Include';
1335
1338
  const ManyResultsInManyFiles = '{PH1} results in {PH2} files';
1336
1339
  const ManyResultsInOneFile = '{PH1} results in 1 file';
1337
1340
  const MatchCase$1 = 'Match Case';
@@ -1343,13 +1346,13 @@ const Replace = 'Replace';
1343
1346
  const ReplaceAll$1 = 'Replace All';
1344
1347
  const ReplacedManyOccurrencesInManyFiles = "Replaced {PH1} occurrences across {PH2} files with '{PH3}'";
1345
1348
  const ReplacedOneOccurrenceInOneFile = "Replaced 1 occurrence across 1 file with '{PH1}'";
1349
+ const Search$2 = 'Search';
1350
+ const SearchForHistory = 'Search (⇅ for history)';
1351
+ const SearchOnlyOpenEditors$1 = 'Search Only Open Editors';
1346
1352
  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
1353
  const ToggleSearchDetails$1 = 'Toggle Search Details';
1351
- const SearchOnlyOpenEditors$1 = 'Search Only Open Editors';
1352
1354
  const UseExcludeSettings$1 = 'Use Exclude Settings';
1355
+ const UseRegularExpression$1 = 'Use Regular Expression';
1353
1356
 
1354
1357
  const noResults = () => {
1355
1358
  return i18nString(NoResults);
@@ -1454,6 +1457,12 @@ const searchOnlyOpenEditors = () => {
1454
1457
  const useExcludeSettings = () => {
1455
1458
  return i18nString(UseExcludeSettings$1);
1456
1459
  };
1460
+ const searchForHistory = () => {
1461
+ return i18nString(SearchForHistory);
1462
+ };
1463
+ const search = () => {
1464
+ return i18nString(Search$2);
1465
+ };
1457
1466
 
1458
1467
  const getStatusMessage = (resultCount, fileResultCount) => {
1459
1468
  if (resultCount === 0) {
@@ -1717,7 +1726,12 @@ const focusReplaceValue$1 = state => {
1717
1726
  };
1718
1727
  };
1719
1728
 
1720
- const focusSearchValue$1 = state => {
1729
+ const setFocus = async focusKey => {
1730
+ await invoke$2('Focus.setFocus', focusKey);
1731
+ };
1732
+
1733
+ const focusSearchValue$1 = async state => {
1734
+ await setFocus(FocusSearchInput);
1721
1735
  return {
1722
1736
  ...state,
1723
1737
  focus: FocusSearchInput
@@ -1731,7 +1745,7 @@ const focusSearchValueNext = state => {
1731
1745
  return focusMatchCase$1(state);
1732
1746
  };
1733
1747
 
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'];
1748
+ 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
1749
 
1736
1750
  const getCommandIds = () => {
1737
1751
  return commandIds;
@@ -1766,11 +1780,11 @@ const getKeyBindings = () => {
1766
1780
  }, {
1767
1781
  key: UpArrow,
1768
1782
  command: 'Search.previousHistoryResult',
1769
- when: FocusSearch
1783
+ when: FocusSearchInput
1770
1784
  }, {
1771
1785
  key: DownArrow,
1772
1786
  command: 'Search.nextHistoryResult',
1773
- when: FocusSearch
1787
+ when: FocusSearchInput
1774
1788
  }, {
1775
1789
  key: DownArrow,
1776
1790
  command: 'Search.focusNext',
@@ -2370,6 +2384,8 @@ const getClickHandler = name => {
2370
2384
  return toggleOpenEditors;
2371
2385
  case UseExcludeSettings:
2372
2386
  return toggleUseIgnoreFiles;
2387
+ case SearchValue:
2388
+ return focusSearchValue$1;
2373
2389
  default:
2374
2390
  return noop;
2375
2391
  }
@@ -2384,6 +2400,17 @@ const handleHeaderFocusIn = state => {
2384
2400
  return state;
2385
2401
  };
2386
2402
 
2403
+ const handleHeaderFocusOut = state => {
2404
+ if (!state.focus) {
2405
+ return state;
2406
+ }
2407
+ return {
2408
+ ...state,
2409
+ focused: false,
2410
+ focus: 0
2411
+ };
2412
+ };
2413
+
2387
2414
  const handleIconThemeChange = async state => {
2388
2415
  const {
2389
2416
  items,
@@ -2719,7 +2746,7 @@ const handleWheel = (state, deltaMode, deltaY) => {
2719
2746
  const getListIndex = (eventX, eventY, x, y, deltaY, itemHeight, topHeight, itemCount) => {
2720
2747
  const relativeY = eventY - y - topHeight + deltaY;
2721
2748
  const index = Math.floor(relativeY / itemHeight);
2722
- if (index >= itemCount) {
2749
+ if (index < 0 || index >= itemCount) {
2723
2750
  return -1;
2724
2751
  }
2725
2752
  return index;
@@ -2882,6 +2909,16 @@ const handleClickAt = (state, eventX, eventY) => {
2882
2909
  return selectIndex(state, index);
2883
2910
  };
2884
2911
 
2912
+ const isString = value => {
2913
+ return typeof value === 'string';
2914
+ };
2915
+ const getSavedHistory = savedState => {
2916
+ if (savedState && typeof savedState === 'object' && 'history' in savedState && Array.isArray(savedState.history) && savedState.history.every(isString)) {
2917
+ return savedState.history;
2918
+ }
2919
+ return [];
2920
+ };
2921
+
2885
2922
  const getSavedValue = savedState => {
2886
2923
  if (savedState && typeof savedState === 'object' && 'value' in savedState && typeof savedState.value === 'string') {
2887
2924
  return savedState.value;
@@ -2921,7 +2958,8 @@ const restoreState = savedState => {
2921
2958
  threads: 1,
2922
2959
  flags: getSavedFlags(savedState),
2923
2960
  includeValue: getSavedIncludeValue(savedState),
2924
- excludeValue: getSavedExcludeValue(savedState)
2961
+ excludeValue: getSavedExcludeValue(savedState),
2962
+ history: getSavedHistory(savedState)
2925
2963
  };
2926
2964
  };
2927
2965
 
@@ -2955,12 +2993,40 @@ const loadContent = async (state, savedState) => {
2955
2993
  };
2956
2994
  };
2957
2995
 
2958
- const nextHistoryResult = async state => {
2996
+ const getNextHistoryData = (history, historyIndex) => {
2997
+ if (historyIndex === -1 || history.length === 0) {
2998
+ return {
2999
+ newValue: '',
3000
+ newHistoryIndex: -1
3001
+ };
3002
+ }
3003
+ const item = history.at(historyIndex) || '';
2959
3004
  return {
2960
- ...state
3005
+ newValue: item,
3006
+ newHistoryIndex: historyIndex + 1
2961
3007
  };
2962
3008
  };
2963
3009
 
3010
+ const nextHistoryResult = async state => {
3011
+ const {
3012
+ history,
3013
+ historyIndex,
3014
+ value
3015
+ } = state;
3016
+ const {
3017
+ newValue,
3018
+ newHistoryIndex
3019
+ } = getNextHistoryData(history, historyIndex);
3020
+ if (newValue === value) {
3021
+ return state;
3022
+ }
3023
+ return handleUpdate(state, {
3024
+ value: newValue,
3025
+ inputSource: Script,
3026
+ historyIndex: newHistoryIndex
3027
+ });
3028
+ };
3029
+
2964
3030
  const previousHistoryResult = async state => {
2965
3031
  return {
2966
3032
  ...state
@@ -3132,7 +3198,8 @@ const createViewModel = state => {
3132
3198
  message,
3133
3199
  searchInputErrorMessage,
3134
3200
  scrollBarHeight,
3135
- matchCount
3201
+ matchCount,
3202
+ focus
3136
3203
  } = state;
3137
3204
  const displayResults = getDisplayResults(listItems, itemHeight, fileCount, value, minLineY, maxLineY, replacement, icons, listFocusedIndex, collapsedPaths, items);
3138
3205
  const focusOutline = listFocused && listFocusedIndex === -1;
@@ -3149,7 +3216,8 @@ const createViewModel = state => {
3149
3216
  scrollBarValue,
3150
3217
  deltaY,
3151
3218
  itemHeight,
3152
- matchCount
3219
+ matchCount,
3220
+ focus
3153
3221
  };
3154
3222
  };
3155
3223
 
@@ -3222,19 +3290,20 @@ const Tree = 'tree';
3222
3290
  const TreeItem = 'treeitem';
3223
3291
 
3224
3292
  const HandleClick = 'handleClick';
3293
+ const HandleContextMenu = 'handleContextMenu';
3225
3294
  const HandleExcludeInput = 'handleExcludeInput';
3226
3295
  const HandleHeaderClick2 = 'handleHeaderClick2';
3227
3296
  const HandleHeaderFocusIn = 'handleHeaderFocusIn';
3297
+ const HandleHeaderFocusOut = 'handleHeaderFocusOut';
3228
3298
  const HandleIncludeInput = 'handleIncludeInput';
3229
3299
  const HandleInput = 'handleInput';
3230
3300
  const HandleInput2 = 'handleInput2';
3231
3301
  const HandleListBlur = 'handleListBlur';
3302
+ const HandleListFocus = 'handleListFocus';
3232
3303
  const HandleReplaceInput = 'handleReplaceInput';
3233
3304
  const HandleScrollBarPointerDown = 'handleScrollBarPointerDown';
3234
3305
  const HandleToggleButtonClick = 'handleToggleButtonClick';
3235
3306
  const HandleWheel = 'handleWheel';
3236
- const HandleListFocus = 'handleListFocus';
3237
- const HandleContextMenu = 'handleContextMenu';
3238
3307
 
3239
3308
  const mergeClassNames = (...classNames) => {
3240
3309
  return classNames.filter(Boolean).join(' ');
@@ -3726,6 +3795,13 @@ const getInputActionsReplace = (flags, matchCount) => {
3726
3795
  };
3727
3796
  };
3728
3797
 
3798
+ const getSearchPlaceholder = focus => {
3799
+ if (focus === FocusSearchInput) {
3800
+ return searchForHistory();
3801
+ }
3802
+ return search();
3803
+ };
3804
+
3729
3805
  const getSearchToggleVirtualDom = flags => {
3730
3806
  return [{
3731
3807
  type: Button$1,
@@ -3743,9 +3819,10 @@ const getSearchToggleVirtualDom = flags => {
3743
3819
  }];
3744
3820
  };
3745
3821
 
3746
- const getSearchHeaderTopVirtualDom = (flags, searchInputErrorMessage, matchCount) => {
3822
+ const getSearchHeaderTopVirtualDom = (flags, searchInputErrorMessage, matchCount, focus) => {
3747
3823
  const inputActions = getInputActionsInput(flags);
3748
3824
  const replaceActions = getInputActionsReplace(flags, matchCount);
3825
+ const placeholder = getSearchPlaceholder(focus);
3749
3826
  const dom = [{
3750
3827
  type: Div,
3751
3828
  className: SearchHeaderTop,
@@ -3756,9 +3833,9 @@ const getSearchHeaderTopVirtualDom = (flags, searchInputErrorMessage, matchCount
3756
3833
  className: SearchHeaderTopRight,
3757
3834
  role: None,
3758
3835
  childCount: flags & ReplaceExpanded ? 2 : 1
3759
- }, ...getSearchFieldVirtualDom(SearchValue, 'Search', HandleInput2, inputActions.inside, inputActions.outside, '', Boolean(searchInputErrorMessage))];
3836
+ }, ...getSearchFieldVirtualDom(SearchValue, placeholder, HandleInput2, inputActions.inside, inputActions.outside, '', Boolean(searchInputErrorMessage))];
3760
3837
  if (flags & ReplaceExpanded) {
3761
- dom.push(...getSearchFieldVirtualDom(ReplaceValue, 'Replace', HandleInput2, replaceActions.inside, replaceActions.outside));
3838
+ dom.push(...getSearchFieldVirtualDom(ReplaceValue, replace(), HandleInput2, replaceActions.inside, replaceActions.outside));
3762
3839
  }
3763
3840
  return dom;
3764
3841
  };
@@ -3769,10 +3846,11 @@ const parentNode = {
3769
3846
  role: None,
3770
3847
  childCount: 2,
3771
3848
  onClick: HandleHeaderClick2,
3772
- onFocusIn: HandleHeaderFocusIn
3849
+ onFocusIn: HandleHeaderFocusIn,
3850
+ onFocusOut: HandleHeaderFocusOut
3773
3851
  };
3774
- const getSearchHeaderVirtualDom = (flags, message, searchInputErrorMessage, matchCount) => {
3775
- const dom = [parentNode, ...getSearchHeaderTopVirtualDom(flags, searchInputErrorMessage, matchCount), ...getSearchHeaderDetailsVirtualDom(flags, message)];
3852
+ const getSearchHeaderVirtualDom = (flags, message, searchInputErrorMessage, matchCount, focus) => {
3853
+ const dom = [parentNode, ...getSearchHeaderTopVirtualDom(flags, searchInputErrorMessage, matchCount, focus), ...getSearchHeaderDetailsVirtualDom(flags, message)];
3776
3854
  return dom;
3777
3855
  };
3778
3856
 
@@ -3988,33 +4066,33 @@ const getSearchResultsVirtualDom = (visibleItems, focusOutline, scrollbarHeight,
3988
4066
  }, ...getTreeItemsVirtualDom(visibleItems, deltaY, itemHeight), ...getScrollBarVirtualDom(scrollbarHeight, scrollBarY, scrollBarValue)];
3989
4067
  };
3990
4068
 
3991
- const getSearchVirtualDom = (visibleItems, flags, message, focusOutline, searchInputErrorMessage, scrollBarHeight, scrollBarY, scrollBarValue, deltaY, itemHeight, matchCount) => {
4069
+ const getSearchVirtualDom = (visibleItems, flags, message, focusOutline, searchInputErrorMessage, scrollBarHeight, scrollBarY, scrollBarValue, deltaY, itemHeight, matchCount, focus = 0) => {
3992
4070
  const errorDom = getSearchInputErrorVirtualDom(searchInputErrorMessage);
3993
4071
  const childCount = 2 + (errorDom.length > 0 ? 1 : 0);
3994
4072
  return [{
3995
4073
  type: Div,
3996
4074
  className: mergeClassNames(Viewlet, Search$1),
3997
4075
  childCount
3998
- }, ...getSearchHeaderVirtualDom(flags, message, searchInputErrorMessage, matchCount), ...errorDom, ...getSearchResultsVirtualDom(visibleItems, focusOutline, scrollBarHeight, scrollBarY, scrollBarValue, deltaY, itemHeight)];
4076
+ }, ...getSearchHeaderVirtualDom(flags, message, searchInputErrorMessage, matchCount, focus), ...errorDom, ...getSearchResultsVirtualDom(visibleItems, focusOutline, scrollBarHeight, scrollBarY, scrollBarValue, deltaY, itemHeight)];
3999
4077
  };
4000
4078
 
4001
4079
  const renderItems = (oldState, newState) => {
4002
4080
  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);
4081
+ 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
4082
  return ['Viewlet.setDom2', newState.uid, dom];
4005
4083
  };
4006
4084
 
4007
4085
  const renderValue = (oldState, newState) => {
4008
- return ['Viewlet.send', newState.uid, 'setValue', newState.value, `[name="${SearchValue}"]`];
4086
+ return ['Viewlet.setValueByName', SearchValue, newState.value];
4009
4087
  };
4010
4088
  const renderReplacement = (oldState, newState) => {
4011
- return ['Viewlet.send', newState.uid, 'setValue', newState.replacement, `[name=${ReplaceValue}]`];
4089
+ return ['Viewlet.setValueByName', ReplaceValue, newState.replacement];
4012
4090
  };
4013
4091
  const renderIncludeValue = (oldState, newState) => {
4014
- return ['Viewlet.send', newState.uid, 'setValue', newState.includeValue, `[name=${FilesToInclude}]`];
4092
+ return ['Viewlet.setValueByName', FilesToInclude, newState.includeValue];
4015
4093
  };
4016
4094
  const renderExcludeValue = (oldState, newState) => {
4017
- return ['Viewlet.send', newState.uid, 'setValue', newState.excludeValue, `[name=${FilesToExclude}]`];
4095
+ return ['Viewlet.setValueByName', FilesToExclude, newState.excludeValue];
4018
4096
  };
4019
4097
 
4020
4098
  const getRenderer = diffType => {
@@ -4154,6 +4232,9 @@ const renderEventListeners = () => {
4154
4232
  }, {
4155
4233
  name: HandleHeaderFocusIn,
4156
4234
  params: ['handleHeaderFocusIn']
4235
+ }, {
4236
+ name: HandleHeaderFocusOut,
4237
+ params: ['handleHeaderFocusOut']
4157
4238
  }, {
4158
4239
  name: HandleScrollBarPointerDown,
4159
4240
  params: ['handleScrollBarClick', 'event.deltaY']
@@ -4165,7 +4246,7 @@ const getDom = state => {
4165
4246
  const focusOutline = state.listFocused && state.listFocusedIndex === -1;
4166
4247
  const scrollBarValue = state.deltaY / state.finalDeltaY * 100;
4167
4248
  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);
4249
+ const dom = getSearchVirtualDom(displayResults, state.flags, state.message, focusOutline, state.searchInputErrorMessage, state.scrollBarHeight, scrollBarY, scrollBarValue, state.deltaY, state.itemHeight, state.matchCount, state.focus);
4169
4250
  return dom;
4170
4251
  };
4171
4252
 
@@ -4255,10 +4336,6 @@ const focusElement = (state, focusKey) => {
4255
4336
  };
4256
4337
  };
4257
4338
 
4258
- const setFocus = async focusKey => {
4259
- await invoke$2('Focus.setFocus', focusKey);
4260
- };
4261
-
4262
4339
  const getSearchFocusKey = key => {
4263
4340
  switch (key) {
4264
4341
  case SearchValue:
@@ -4292,12 +4369,12 @@ const getSearchFocusKey = key => {
4292
4369
  }
4293
4370
  };
4294
4371
 
4295
- const handleFocusIn = (state, key) => {
4372
+ const handleFocusIn = async (state, key) => {
4296
4373
  const focusKey = getSearchFocusKey(key);
4297
4374
  if (state.focus === focusKey) {
4298
4375
  return state;
4299
4376
  }
4300
- void setFocus(FocusSearch);
4377
+ await setFocus(FocusSearch);
4301
4378
  return {
4302
4379
  ...state,
4303
4380
  focus: focusKey,
@@ -4345,10 +4422,18 @@ const focusReplaceAll = state => {
4345
4422
  return focusElement(state, FocusSearchReplaceAll);
4346
4423
  };
4347
4424
 
4425
+ const getNewHistory = (history, newValue) => {
4426
+ const newHistory = [...history, newValue];
4427
+ const maxHistoryLength = 100;
4428
+ const cutHistory = newHistory.slice(0, maxHistoryLength);
4429
+ return cutHistory;
4430
+ };
4348
4431
  const submit = state => {
4432
+ const newHistory = getNewHistory(state.history, state.value);
4349
4433
  return handleUpdate(state, {
4350
4434
  value: state.value,
4351
- inputSource: User
4435
+ inputSource: User,
4436
+ history: newHistory
4352
4437
  });
4353
4438
  };
4354
4439
 
@@ -4451,6 +4536,7 @@ const commandMap = {
4451
4536
  'TextSearch.handleFocusIn': wrapCommand(handleFocusIn),
4452
4537
  'TextSearch.handleHeaderClick': wrapCommand(handleHeaderClick),
4453
4538
  'TextSearch.handleHeaderFocusIn': wrapCommand(handleHeaderFocusIn),
4539
+ 'TextSearch.handleHeaderFocusOut': wrapCommand(handleHeaderFocusOut),
4454
4540
  'TextSearch.handleIconThemeChange': wrapCommand(handleIconThemeChange),
4455
4541
  'TextSearch.handleIncludeInput': wrapCommand(handleIncludeInput),
4456
4542
  '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.4.0",
4
4
  "description": "Text Search Worker",
5
5
  "keywords": [
6
6
  "text-search"