@lvce-editor/text-search-worker 4.2.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.
@@ -1241,7 +1241,9 @@ const create = (uid, x, y, width, height, workspacePath, assetDir, itemHeight, v
1241
1241
  focusSource: User,
1242
1242
  flags: 0,
1243
1243
  platform,
1244
- searchInputErrorMessage: ''
1244
+ searchInputErrorMessage: '',
1245
+ history: [],
1246
+ historyIndex: -1
1245
1247
  };
1246
1248
  set(uid, state, state);
1247
1249
  return state;
@@ -1271,7 +1273,7 @@ const isEqual$3 = (oldState, newState) => {
1271
1273
 
1272
1274
  const diffType$2 = RenderItems;
1273
1275
  const isEqual$2 = (oldState, newState) => {
1274
- 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;
1275
1277
  };
1276
1278
 
1277
1279
  const diffType$1 = RenderReplaceValue;
@@ -1331,6 +1333,8 @@ const ConfirmReplaceManyOccurrencesInOneFile = "Replace {PH1} occurrences across
1331
1333
  const ConfirmReplaceManyOccurrencesInOneFileNoValue = 'Replace {PH1} occurrences across 1 file';
1332
1334
  const ConfirmReplaceOneOccurrenceInOneFile = "Replace 1 occurrence across 1 file with '{PH1}'";
1333
1335
  const ConfirmReplaceOneOccurrenceInOneFileNoValue = 'Replace 1 occurrence across 1 file';
1336
+ const FilesToExclude$1 = 'Files to Exclude';
1337
+ const FilesToInclude$1 = 'Files to Include';
1334
1338
  const ManyResultsInManyFiles = '{PH1} results in {PH2} files';
1335
1339
  const ManyResultsInOneFile = '{PH1} results in 1 file';
1336
1340
  const MatchCase$1 = 'Match Case';
@@ -1342,13 +1346,13 @@ const Replace = 'Replace';
1342
1346
  const ReplaceAll$1 = 'Replace All';
1343
1347
  const ReplacedManyOccurrencesInManyFiles = "Replaced {PH1} occurrences across {PH2} files with '{PH3}'";
1344
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';
1345
1352
  const ToggleReplace$1 = 'Toggle Replace';
1346
- const UseRegularExpression$1 = 'Use Regular Expression';
1347
- const FilesToInclude$1 = 'Files to Include';
1348
- const FilesToExclude$1 = 'Files to Exclude';
1349
1353
  const ToggleSearchDetails$1 = 'Toggle Search Details';
1350
- const SearchOnlyOpenEditors$1 = 'Search Only Open Editors';
1351
1354
  const UseExcludeSettings$1 = 'Use Exclude Settings';
1355
+ const UseRegularExpression$1 = 'Use Regular Expression';
1352
1356
 
1353
1357
  const noResults = () => {
1354
1358
  return i18nString(NoResults);
@@ -1453,6 +1457,12 @@ const searchOnlyOpenEditors = () => {
1453
1457
  const useExcludeSettings = () => {
1454
1458
  return i18nString(UseExcludeSettings$1);
1455
1459
  };
1460
+ const searchForHistory = () => {
1461
+ return i18nString(SearchForHistory);
1462
+ };
1463
+ const search = () => {
1464
+ return i18nString(Search$2);
1465
+ };
1456
1466
 
1457
1467
  const getStatusMessage = (resultCount, fileResultCount) => {
1458
1468
  if (resultCount === 0) {
@@ -1716,7 +1726,12 @@ const focusReplaceValue$1 = state => {
1716
1726
  };
1717
1727
  };
1718
1728
 
1719
- 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);
1720
1735
  return {
1721
1736
  ...state,
1722
1737
  focus: FocusSearchInput
@@ -1730,7 +1745,7 @@ const focusSearchValueNext = state => {
1730
1745
  return focusMatchCase$1(state);
1731
1746
  };
1732
1747
 
1733
- 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', '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'];
1734
1749
 
1735
1750
  const getCommandIds = () => {
1736
1751
  return commandIds;
@@ -1762,6 +1777,14 @@ const getKeyBindings = () => {
1762
1777
  key: Shift | Tab,
1763
1778
  command: 'Search.focusPreviousInput',
1764
1779
  when: FocusSearch
1780
+ }, {
1781
+ key: UpArrow,
1782
+ command: 'Search.previousHistoryResult',
1783
+ when: FocusSearchInput
1784
+ }, {
1785
+ key: DownArrow,
1786
+ command: 'Search.nextHistoryResult',
1787
+ when: FocusSearchInput
1765
1788
  }, {
1766
1789
  key: DownArrow,
1767
1790
  command: 'Search.focusNext',
@@ -2361,6 +2384,8 @@ const getClickHandler = name => {
2361
2384
  return toggleOpenEditors;
2362
2385
  case UseExcludeSettings:
2363
2386
  return toggleUseIgnoreFiles;
2387
+ case SearchValue:
2388
+ return focusSearchValue$1;
2364
2389
  default:
2365
2390
  return noop;
2366
2391
  }
@@ -2375,6 +2400,17 @@ const handleHeaderFocusIn = state => {
2375
2400
  return state;
2376
2401
  };
2377
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
+
2378
2414
  const handleIconThemeChange = async state => {
2379
2415
  const {
2380
2416
  items,
@@ -2710,7 +2746,7 @@ const handleWheel = (state, deltaMode, deltaY) => {
2710
2746
  const getListIndex = (eventX, eventY, x, y, deltaY, itemHeight, topHeight, itemCount) => {
2711
2747
  const relativeY = eventY - y - topHeight + deltaY;
2712
2748
  const index = Math.floor(relativeY / itemHeight);
2713
- if (index >= itemCount) {
2749
+ if (index < 0 || index >= itemCount) {
2714
2750
  return -1;
2715
2751
  }
2716
2752
  return index;
@@ -2873,6 +2909,16 @@ const handleClickAt = (state, eventX, eventY) => {
2873
2909
  return selectIndex(state, index);
2874
2910
  };
2875
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
+
2876
2922
  const getSavedValue = savedState => {
2877
2923
  if (savedState && typeof savedState === 'object' && 'value' in savedState && typeof savedState.value === 'string') {
2878
2924
  return savedState.value;
@@ -2912,7 +2958,8 @@ const restoreState = savedState => {
2912
2958
  threads: 1,
2913
2959
  flags: getSavedFlags(savedState),
2914
2960
  includeValue: getSavedIncludeValue(savedState),
2915
- excludeValue: getSavedExcludeValue(savedState)
2961
+ excludeValue: getSavedExcludeValue(savedState),
2962
+ history: getSavedHistory(savedState)
2916
2963
  };
2917
2964
  };
2918
2965
 
@@ -2946,6 +2993,46 @@ const loadContent = async (state, savedState) => {
2946
2993
  };
2947
2994
  };
2948
2995
 
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) || '';
3004
+ return {
3005
+ newValue: item,
3006
+ newHistoryIndex: historyIndex + 1
3007
+ };
3008
+ };
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
+
3030
+ const previousHistoryResult = async state => {
3031
+ return {
3032
+ ...state
3033
+ };
3034
+ };
3035
+
2949
3036
  const refresh = state => {
2950
3037
  return handleUpdate(state, {});
2951
3038
  };
@@ -3111,7 +3198,8 @@ const createViewModel = state => {
3111
3198
  message,
3112
3199
  searchInputErrorMessage,
3113
3200
  scrollBarHeight,
3114
- matchCount
3201
+ matchCount,
3202
+ focus
3115
3203
  } = state;
3116
3204
  const displayResults = getDisplayResults(listItems, itemHeight, fileCount, value, minLineY, maxLineY, replacement, icons, listFocusedIndex, collapsedPaths, items);
3117
3205
  const focusOutline = listFocused && listFocusedIndex === -1;
@@ -3128,7 +3216,8 @@ const createViewModel = state => {
3128
3216
  scrollBarValue,
3129
3217
  deltaY,
3130
3218
  itemHeight,
3131
- matchCount
3219
+ matchCount,
3220
+ focus
3132
3221
  };
3133
3222
  };
3134
3223
 
@@ -3201,19 +3290,20 @@ const Tree = 'tree';
3201
3290
  const TreeItem = 'treeitem';
3202
3291
 
3203
3292
  const HandleClick = 'handleClick';
3293
+ const HandleContextMenu = 'handleContextMenu';
3204
3294
  const HandleExcludeInput = 'handleExcludeInput';
3205
3295
  const HandleHeaderClick2 = 'handleHeaderClick2';
3206
3296
  const HandleHeaderFocusIn = 'handleHeaderFocusIn';
3297
+ const HandleHeaderFocusOut = 'handleHeaderFocusOut';
3207
3298
  const HandleIncludeInput = 'handleIncludeInput';
3208
3299
  const HandleInput = 'handleInput';
3209
3300
  const HandleInput2 = 'handleInput2';
3210
3301
  const HandleListBlur = 'handleListBlur';
3302
+ const HandleListFocus = 'handleListFocus';
3211
3303
  const HandleReplaceInput = 'handleReplaceInput';
3212
3304
  const HandleScrollBarPointerDown = 'handleScrollBarPointerDown';
3213
3305
  const HandleToggleButtonClick = 'handleToggleButtonClick';
3214
3306
  const HandleWheel = 'handleWheel';
3215
- const HandleListFocus = 'handleListFocus';
3216
- const HandleContextMenu = 'handleContextMenu';
3217
3307
 
3218
3308
  const mergeClassNames = (...classNames) => {
3219
3309
  return classNames.filter(Boolean).join(' ');
@@ -3705,6 +3795,13 @@ const getInputActionsReplace = (flags, matchCount) => {
3705
3795
  };
3706
3796
  };
3707
3797
 
3798
+ const getSearchPlaceholder = focus => {
3799
+ if (focus === FocusSearchInput) {
3800
+ return searchForHistory();
3801
+ }
3802
+ return search();
3803
+ };
3804
+
3708
3805
  const getSearchToggleVirtualDom = flags => {
3709
3806
  return [{
3710
3807
  type: Button$1,
@@ -3722,9 +3819,10 @@ const getSearchToggleVirtualDom = flags => {
3722
3819
  }];
3723
3820
  };
3724
3821
 
3725
- const getSearchHeaderTopVirtualDom = (flags, searchInputErrorMessage, matchCount) => {
3822
+ const getSearchHeaderTopVirtualDom = (flags, searchInputErrorMessage, matchCount, focus) => {
3726
3823
  const inputActions = getInputActionsInput(flags);
3727
3824
  const replaceActions = getInputActionsReplace(flags, matchCount);
3825
+ const placeholder = getSearchPlaceholder(focus);
3728
3826
  const dom = [{
3729
3827
  type: Div,
3730
3828
  className: SearchHeaderTop,
@@ -3735,9 +3833,9 @@ const getSearchHeaderTopVirtualDom = (flags, searchInputErrorMessage, matchCount
3735
3833
  className: SearchHeaderTopRight,
3736
3834
  role: None,
3737
3835
  childCount: flags & ReplaceExpanded ? 2 : 1
3738
- }, ...getSearchFieldVirtualDom(SearchValue, 'Search', HandleInput2, inputActions.inside, inputActions.outside, '', Boolean(searchInputErrorMessage))];
3836
+ }, ...getSearchFieldVirtualDom(SearchValue, placeholder, HandleInput2, inputActions.inside, inputActions.outside, '', Boolean(searchInputErrorMessage))];
3739
3837
  if (flags & ReplaceExpanded) {
3740
- dom.push(...getSearchFieldVirtualDom(ReplaceValue, 'Replace', HandleInput2, replaceActions.inside, replaceActions.outside));
3838
+ dom.push(...getSearchFieldVirtualDom(ReplaceValue, replace(), HandleInput2, replaceActions.inside, replaceActions.outside));
3741
3839
  }
3742
3840
  return dom;
3743
3841
  };
@@ -3748,10 +3846,11 @@ const parentNode = {
3748
3846
  role: None,
3749
3847
  childCount: 2,
3750
3848
  onClick: HandleHeaderClick2,
3751
- onFocusIn: HandleHeaderFocusIn
3849
+ onFocusIn: HandleHeaderFocusIn,
3850
+ onFocusOut: HandleHeaderFocusOut
3752
3851
  };
3753
- const getSearchHeaderVirtualDom = (flags, message, searchInputErrorMessage, matchCount) => {
3754
- 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)];
3755
3854
  return dom;
3756
3855
  };
3757
3856
 
@@ -3967,33 +4066,33 @@ const getSearchResultsVirtualDom = (visibleItems, focusOutline, scrollbarHeight,
3967
4066
  }, ...getTreeItemsVirtualDom(visibleItems, deltaY, itemHeight), ...getScrollBarVirtualDom(scrollbarHeight, scrollBarY, scrollBarValue)];
3968
4067
  };
3969
4068
 
3970
- 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) => {
3971
4070
  const errorDom = getSearchInputErrorVirtualDom(searchInputErrorMessage);
3972
4071
  const childCount = 2 + (errorDom.length > 0 ? 1 : 0);
3973
4072
  return [{
3974
4073
  type: Div,
3975
4074
  className: mergeClassNames(Viewlet, Search$1),
3976
4075
  childCount
3977
- }, ...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)];
3978
4077
  };
3979
4078
 
3980
4079
  const renderItems = (oldState, newState) => {
3981
4080
  const viewModel = createViewModel(newState);
3982
- 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);
3983
4082
  return ['Viewlet.setDom2', newState.uid, dom];
3984
4083
  };
3985
4084
 
3986
4085
  const renderValue = (oldState, newState) => {
3987
- return ['Viewlet.send', newState.uid, 'setValue', newState.value, `[name="${SearchValue}"]`];
4086
+ return ['Viewlet.setValueByName', SearchValue, newState.value];
3988
4087
  };
3989
4088
  const renderReplacement = (oldState, newState) => {
3990
- return ['Viewlet.send', newState.uid, 'setValue', newState.replacement, `[name=${ReplaceValue}]`];
4089
+ return ['Viewlet.setValueByName', ReplaceValue, newState.replacement];
3991
4090
  };
3992
4091
  const renderIncludeValue = (oldState, newState) => {
3993
- return ['Viewlet.send', newState.uid, 'setValue', newState.includeValue, `[name=${FilesToInclude}]`];
4092
+ return ['Viewlet.setValueByName', FilesToInclude, newState.includeValue];
3994
4093
  };
3995
4094
  const renderExcludeValue = (oldState, newState) => {
3996
- return ['Viewlet.send', newState.uid, 'setValue', newState.excludeValue, `[name=${FilesToExclude}]`];
4095
+ return ['Viewlet.setValueByName', FilesToExclude, newState.excludeValue];
3997
4096
  };
3998
4097
 
3999
4098
  const getRenderer = diffType => {
@@ -4133,6 +4232,9 @@ const renderEventListeners = () => {
4133
4232
  }, {
4134
4233
  name: HandleHeaderFocusIn,
4135
4234
  params: ['handleHeaderFocusIn']
4235
+ }, {
4236
+ name: HandleHeaderFocusOut,
4237
+ params: ['handleHeaderFocusOut']
4136
4238
  }, {
4137
4239
  name: HandleScrollBarPointerDown,
4138
4240
  params: ['handleScrollBarClick', 'event.deltaY']
@@ -4144,7 +4246,7 @@ const getDom = state => {
4144
4246
  const focusOutline = state.listFocused && state.listFocusedIndex === -1;
4145
4247
  const scrollBarValue = state.deltaY / state.finalDeltaY * 100;
4146
4248
  const scrollBarY = getScrollBarY$1(state.deltaY, state.finalDeltaY, state.height - state.headerHeight, state.scrollBarHeight);
4147
- 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);
4148
4250
  return dom;
4149
4251
  };
4150
4252
 
@@ -4213,14 +4315,16 @@ const saveState = uid => {
4213
4315
  replacement,
4214
4316
  flags,
4215
4317
  includeValue,
4216
- excludeValue
4318
+ excludeValue,
4319
+ history
4217
4320
  } = newState;
4218
4321
  return {
4219
4322
  value,
4220
4323
  replacement,
4221
4324
  flags,
4222
4325
  includeValue,
4223
- excludeValue
4326
+ excludeValue,
4327
+ history
4224
4328
  };
4225
4329
  };
4226
4330
 
@@ -4232,10 +4336,6 @@ const focusElement = (state, focusKey) => {
4232
4336
  };
4233
4337
  };
4234
4338
 
4235
- const setFocus = async focusKey => {
4236
- await invoke$2('Focus.setFocus', focusKey);
4237
- };
4238
-
4239
4339
  const getSearchFocusKey = key => {
4240
4340
  switch (key) {
4241
4341
  case SearchValue:
@@ -4269,12 +4369,12 @@ const getSearchFocusKey = key => {
4269
4369
  }
4270
4370
  };
4271
4371
 
4272
- const handleFocusIn = (state, key) => {
4372
+ const handleFocusIn = async (state, key) => {
4273
4373
  const focusKey = getSearchFocusKey(key);
4274
4374
  if (state.focus === focusKey) {
4275
4375
  return state;
4276
4376
  }
4277
- void setFocus(FocusSearch);
4377
+ await setFocus(FocusSearch);
4278
4378
  return {
4279
4379
  ...state,
4280
4380
  focus: focusKey,
@@ -4322,10 +4422,18 @@ const focusReplaceAll = state => {
4322
4422
  return focusElement(state, FocusSearchReplaceAll);
4323
4423
  };
4324
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
+ };
4325
4431
  const submit = state => {
4432
+ const newHistory = getNewHistory(state.history, state.value);
4326
4433
  return handleUpdate(state, {
4327
4434
  value: state.value,
4328
- inputSource: User
4435
+ inputSource: User,
4436
+ history: newHistory
4329
4437
  });
4330
4438
  };
4331
4439
 
@@ -4428,6 +4536,7 @@ const commandMap = {
4428
4536
  'TextSearch.handleFocusIn': wrapCommand(handleFocusIn),
4429
4537
  'TextSearch.handleHeaderClick': wrapCommand(handleHeaderClick),
4430
4538
  'TextSearch.handleHeaderFocusIn': wrapCommand(handleHeaderFocusIn),
4539
+ 'TextSearch.handleHeaderFocusOut': wrapCommand(handleHeaderFocusOut),
4431
4540
  'TextSearch.handleIconThemeChange': wrapCommand(handleIconThemeChange),
4432
4541
  'TextSearch.handleIncludeInput': wrapCommand(handleIncludeInput),
4433
4542
  'TextSearch.handleInput': wrapCommand(handleInput),
@@ -4441,6 +4550,8 @@ const commandMap = {
4441
4550
  'TextSearch.handleWheel': wrapCommand(handleWheel),
4442
4551
  'TextSearch.launchSearchProcess': wrapCommand(launchSearchProcess),
4443
4552
  'TextSearch.loadContent': wrapCommand(loadContent),
4553
+ 'TextSearch.nextHistoryResult': wrapCommand(nextHistoryResult),
4554
+ 'TextSearch.previousHistoryResult': wrapCommand(previousHistoryResult),
4444
4555
  'TextSearch.refresh': wrapCommand(refresh),
4445
4556
  'TextSearch.renderActions': renderActions,
4446
4557
  'TextSearch.replaceAll': wrapCommand(replaceAll),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/text-search-worker",
3
- "version": "4.2.0",
3
+ "version": "4.4.0",
4
4
  "description": "Text Search Worker",
5
5
  "keywords": [
6
6
  "text-search"