@codingame/monaco-vscode-search-service-override 3.2.3 → 4.1.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.
Files changed (35) hide show
  1. package/package.json +2 -2
  2. package/search.js +4 -4
  3. package/external/rollup-plugin-styles/dist/runtime/inject-css.js +0 -3
  4. package/external/tslib/tslib.es6.js +0 -11
  5. package/override/vs/platform/dialogs/common/dialogs.js +0 -8
  6. package/vscode/src/vs/workbench/contrib/search/browser/anythingQuickAccess.js +0 -776
  7. package/vscode/src/vs/workbench/contrib/search/browser/media/anythingQuickAccess.css.js +0 -6
  8. package/vscode/src/vs/workbench/contrib/search/browser/media/searchview.css.js +0 -6
  9. package/vscode/src/vs/workbench/contrib/search/browser/patternInputWidget.js +0 -231
  10. package/vscode/src/vs/workbench/contrib/search/browser/quickTextSearch/textSearchQuickAccess.js +0 -342
  11. package/vscode/src/vs/workbench/contrib/search/browser/replaceContributions.js +0 -8
  12. package/vscode/src/vs/workbench/contrib/search/browser/replaceService.js +0 -232
  13. package/vscode/src/vs/workbench/contrib/search/browser/search.contribution.js +0 -621
  14. package/vscode/src/vs/workbench/contrib/search/browser/searchActionsCopy.js +0 -209
  15. package/vscode/src/vs/workbench/contrib/search/browser/searchActionsNav.js +0 -511
  16. package/vscode/src/vs/workbench/contrib/search/browser/searchActionsRemoveReplace.js +0 -374
  17. package/vscode/src/vs/workbench/contrib/search/browser/searchActionsSymbol.js +0 -43
  18. package/vscode/src/vs/workbench/contrib/search/browser/searchActionsTextQuickAccess.js +0 -44
  19. package/vscode/src/vs/workbench/contrib/search/browser/searchActionsTopBar.js +0 -323
  20. package/vscode/src/vs/workbench/contrib/search/browser/searchFindInput.js +0 -47
  21. package/vscode/src/vs/workbench/contrib/search/browser/searchIcons.js +0 -96
  22. package/vscode/src/vs/workbench/contrib/search/browser/searchMessage.js +0 -66
  23. package/vscode/src/vs/workbench/contrib/search/browser/searchResultsView.js +0 -434
  24. package/vscode/src/vs/workbench/contrib/search/browser/searchView.js +0 -2096
  25. package/vscode/src/vs/workbench/contrib/search/browser/searchWidget.js +0 -667
  26. package/vscode/src/vs/workbench/contrib/search/browser/symbolsQuickAccess.js +0 -234
  27. package/vscode/src/vs/workbench/contrib/search/common/cacheState.js +0 -87
  28. package/vscode/src/vs/workbench/contrib/searchEditor/browser/media/searchEditor.css.js +0 -6
  29. package/vscode/src/vs/workbench/contrib/searchEditor/browser/searchEditor.contribution.js +0 -586
  30. package/vscode/src/vs/workbench/contrib/searchEditor/browser/searchEditor.js +0 -736
  31. package/vscode/src/vs/workbench/contrib/searchEditor/browser/searchEditorActions.js +0 -189
  32. package/vscode/src/vs/workbench/contrib/searchEditor/browser/searchEditorInput.js +0 -320
  33. package/vscode/src/vs/workbench/contrib/searchEditor/browser/searchEditorModel.js +0 -138
  34. package/vscode/src/vs/workbench/contrib/searchEditor/browser/searchEditorSerialization.js +0 -293
  35. package/vscode/src/vs/workbench/services/search/common/searchService.js +0 -372
@@ -1,667 +0,0 @@
1
- import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
2
- import { append, $, trackFocus } from 'vscode/vscode/vs/base/browser/dom';
3
- import { ActionBar } from 'vscode/vscode/vs/base/browser/ui/actionbar/actionbar';
4
- import { Button } from 'vscode/vscode/vs/base/browser/ui/button/button';
5
- import { InputBox } from 'vscode/vscode/vs/base/browser/ui/inputbox/inputBox';
6
- import { Widget } from 'vscode/vscode/vs/base/browser/ui/widget';
7
- import { Action } from 'vscode/vscode/vs/base/common/actions';
8
- import { Delayer } from 'vscode/vscode/vs/base/common/async';
9
- import { Emitter } from 'vscode/vscode/vs/base/common/event';
10
- import { CONTEXT_FIND_WIDGET_NOT_VISIBLE } from 'vscode/vscode/vs/editor/contrib/find/browser/findModel';
11
- import { localizeWithPath } from 'vscode/vscode/vs/nls';
12
- import { IClipboardService } from 'vscode/vscode/vs/platform/clipboard/common/clipboardService';
13
- import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration';
14
- import { ContextKeyExpr, IContextKeyService } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
15
- import { IContextViewService, IContextMenuService } from 'vscode/vscode/vs/platform/contextview/browser/contextView';
16
- import { IKeybindingService } from 'vscode/vscode/vs/platform/keybinding/common/keybinding';
17
- import { KeybindingsRegistry } from 'vscode/vscode/vs/platform/keybinding/common/keybindingsRegistry';
18
- import { ThemeIcon } from 'vscode/vscode/vs/base/common/themables';
19
- import { ContextScopedReplaceInput } from 'vscode/vscode/vs/platform/history/browser/contextScopedHistoryWidget';
20
- import { appendKeyBindingLabel, isSearchViewFocused, getSearchView } from 'vscode/vscode/vs/workbench/contrib/search/browser/searchActionsBase';
21
- import { SearchContext } from 'vscode/vscode/vs/workbench/contrib/search/common/constants';
22
- import { IAccessibilityService } from 'vscode/vscode/vs/platform/accessibility/common/accessibility';
23
- import { isMacintosh } from 'vscode/vscode/vs/base/common/platform';
24
- import { Toggle } from 'vscode/vscode/vs/base/browser/ui/toggle/toggle';
25
- import { IViewsService } from 'vscode/vscode/vs/workbench/services/views/common/viewsService';
26
- import { searchReplaceAllIcon, searchHideReplaceIcon, searchShowContextIcon, searchShowReplaceIcon } from './searchIcons.js';
27
- import { ToggleSearchEditorContextLinesCommandId } from 'vscode/vscode/vs/workbench/contrib/searchEditor/browser/constants';
28
- import { showHistoryKeybindingHint } from 'vscode/vscode/vs/platform/history/browser/historyWidgetKeybindingHint';
29
- import { defaultToggleStyles, defaultInputBoxStyles } from 'vscode/vscode/vs/platform/theme/browser/defaultStyles';
30
- import { NotebookFindFilters } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/contrib/find/findFilters';
31
- import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
32
- import { IEditorService } from 'vscode/vscode/vs/workbench/services/editor/common/editorService';
33
- import { NotebookEditorInput } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookEditorInput';
34
- import { SearchFindInput } from './searchFindInput.js';
35
-
36
- var SearchWidget_1;
37
- const SingleLineInputHeight = 26;
38
- class ReplaceAllAction extends Action {
39
- static { this.ID = 'search.action.replaceAll'; }
40
- constructor(_searchWidget) {
41
- super(ReplaceAllAction.ID, '', ThemeIcon.asClassName(searchReplaceAllIcon), false);
42
- this._searchWidget = _searchWidget;
43
- }
44
- set searchWidget(searchWidget) {
45
- this._searchWidget = searchWidget;
46
- }
47
- run() {
48
- if (this._searchWidget) {
49
- return this._searchWidget.triggerReplaceAll();
50
- }
51
- return Promise.resolve(null);
52
- }
53
- }
54
- const ctrlKeyMod = ((isMacintosh ? 256 : 2048) );
55
- function stopPropagationForMultiLineUpwards(event, value, textarea) {
56
- const isMultiline = !!value.match(/\n/);
57
- if (textarea && (isMultiline || textarea.clientHeight > SingleLineInputHeight) && textarea.selectionStart > 0) {
58
- event.stopPropagation();
59
- return;
60
- }
61
- }
62
- function stopPropagationForMultiLineDownwards(event, value, textarea) {
63
- const isMultiline = !!value.match(/\n/);
64
- if (textarea && (isMultiline || textarea.clientHeight > SingleLineInputHeight) && textarea.selectionEnd < textarea.value.length) {
65
- event.stopPropagation();
66
- return;
67
- }
68
- }
69
- let SearchWidget = class SearchWidget extends Widget {
70
- static { SearchWidget_1 = this; }
71
- static { this.INPUT_MAX_HEIGHT = 134; }
72
- static { this.REPLACE_ALL_DISABLED_LABEL = ( localizeWithPath(
73
- 'vs/workbench/contrib/search/browser/searchWidget',
74
- 'search.action.replaceAll.disabled.label',
75
- "Replace All (Submit Search to Enable)"
76
- )); }
77
- static { this.REPLACE_ALL_ENABLED_LABEL = (keyBindingService2) => {
78
- const kb = keyBindingService2.lookupKeybinding(ReplaceAllAction.ID);
79
- return appendKeyBindingLabel(( localizeWithPath(
80
- 'vs/workbench/contrib/search/browser/searchWidget',
81
- 'search.action.replaceAll.enabled.label',
82
- "Replace All"
83
- )), kb);
84
- }; }
85
- constructor(container, options, contextViewService, contextKeyService, keybindingService, clipboardServce, configurationService, accessibilityService, contextMenuService, instantiationService, editorService) {
86
- super();
87
- this.contextViewService = contextViewService;
88
- this.contextKeyService = contextKeyService;
89
- this.keybindingService = keybindingService;
90
- this.clipboardServce = clipboardServce;
91
- this.configurationService = configurationService;
92
- this.accessibilityService = accessibilityService;
93
- this.contextMenuService = contextMenuService;
94
- this.instantiationService = instantiationService;
95
- this.editorService = editorService;
96
- this.ignoreGlobalFindBufferOnNextFocus = false;
97
- this.previousGlobalFindBufferValue = null;
98
- this._onSearchSubmit = this._register(( new Emitter()));
99
- this.onSearchSubmit = this._onSearchSubmit.event;
100
- this._onSearchCancel = this._register(( new Emitter()));
101
- this.onSearchCancel = this._onSearchCancel.event;
102
- this._onReplaceToggled = this._register(( new Emitter()));
103
- this.onReplaceToggled = this._onReplaceToggled.event;
104
- this._onReplaceStateChange = this._register(( new Emitter()));
105
- this.onReplaceStateChange = this._onReplaceStateChange.event;
106
- this._onPreserveCaseChange = this._register(( new Emitter()));
107
- this.onPreserveCaseChange = this._onPreserveCaseChange.event;
108
- this._onReplaceValueChanged = this._register(( new Emitter()));
109
- this.onReplaceValueChanged = this._onReplaceValueChanged.event;
110
- this._onReplaceAll = this._register(( new Emitter()));
111
- this.onReplaceAll = this._onReplaceAll.event;
112
- this._onBlur = this._register(( new Emitter()));
113
- this.onBlur = this._onBlur.event;
114
- this._onDidHeightChange = this._register(( new Emitter()));
115
- this.onDidHeightChange = this._onDidHeightChange.event;
116
- this._onDidToggleContext = ( new Emitter());
117
- this.onDidToggleContext = this._onDidToggleContext.event;
118
- this.replaceActive = SearchContext.ReplaceActiveKey.bindTo(this.contextKeyService);
119
- this.searchInputBoxFocused = SearchContext.SearchInputBoxFocusedKey.bindTo(this.contextKeyService);
120
- this.replaceInputBoxFocused = SearchContext.ReplaceInputBoxFocusedKey.bindTo(this.contextKeyService);
121
- const notebookOptions = options.notebookOptions ??
122
- {
123
- isInNotebookMarkdownInput: true,
124
- isInNotebookMarkdownPreview: true,
125
- isInNotebookCellInput: true,
126
- isInNotebookCellOutput: true
127
- };
128
- this._notebookFilters = this._register(( new NotebookFindFilters(
129
- notebookOptions.isInNotebookMarkdownInput,
130
- notebookOptions.isInNotebookMarkdownPreview,
131
- notebookOptions.isInNotebookCellInput,
132
- notebookOptions.isInNotebookCellOutput
133
- )));
134
- this._register(this._notebookFilters.onDidChange(() => {
135
- if (this.searchInput instanceof SearchFindInput) {
136
- this.searchInput.updateStyles();
137
- }
138
- }));
139
- this._register(this.editorService.onDidEditorsChange((e) => {
140
- if (this.searchInput instanceof SearchFindInput &&
141
- e.event.editor instanceof NotebookEditorInput &&
142
- ((e.event.kind === 4 || e.event.kind === 5) )) {
143
- this.searchInput.filterVisible = this._hasNotebookOpen();
144
- }
145
- }));
146
- this._replaceHistoryDelayer = ( new Delayer(500));
147
- this.render(container, options);
148
- this.configurationService.onDidChangeConfiguration(e => {
149
- if (e.affectsConfiguration('editor.accessibilitySupport')) {
150
- this.updateAccessibilitySupport();
151
- }
152
- });
153
- this.accessibilityService.onDidChangeScreenReaderOptimized(() => this.updateAccessibilitySupport());
154
- this.updateAccessibilitySupport();
155
- }
156
- _hasNotebookOpen() {
157
- const editors = this.editorService.editors;
158
- return ( editors.some(editor => editor instanceof NotebookEditorInput));
159
- }
160
- getNotebookFilters() {
161
- return this._notebookFilters;
162
- }
163
- focus(select = true, focusReplace = false, suppressGlobalSearchBuffer = false) {
164
- this.ignoreGlobalFindBufferOnNextFocus = suppressGlobalSearchBuffer;
165
- if (focusReplace && this.isReplaceShown()) {
166
- if (this.replaceInput) {
167
- this.replaceInput.focus();
168
- if (select) {
169
- this.replaceInput.select();
170
- }
171
- }
172
- }
173
- else {
174
- if (this.searchInput) {
175
- this.searchInput.focus();
176
- if (select) {
177
- this.searchInput.select();
178
- }
179
- }
180
- }
181
- }
182
- setWidth(width) {
183
- this.searchInput?.inputBox.layout();
184
- if (this.replaceInput) {
185
- this.replaceInput.width = width - 28;
186
- this.replaceInput.inputBox.layout();
187
- }
188
- }
189
- clear() {
190
- this.searchInput?.clear();
191
- this.replaceInput?.setValue('');
192
- this.setReplaceAllActionState(false);
193
- }
194
- isReplaceShown() {
195
- return this.replaceContainer ? !this.replaceContainer.classList.contains('disabled') : false;
196
- }
197
- isReplaceActive() {
198
- return !!this.replaceActive.get();
199
- }
200
- getReplaceValue() {
201
- return this.replaceInput?.getValue() ?? '';
202
- }
203
- toggleReplace(show) {
204
- if (show === undefined || show !== this.isReplaceShown()) {
205
- this.onToggleReplaceButton();
206
- }
207
- }
208
- getSearchHistory() {
209
- return this.searchInput?.inputBox.getHistory() ?? [];
210
- }
211
- getReplaceHistory() {
212
- return this.replaceInput?.inputBox.getHistory() ?? [];
213
- }
214
- prependSearchHistory(history) {
215
- this.searchInput?.inputBox.prependHistory(history);
216
- }
217
- prependReplaceHistory(history) {
218
- this.replaceInput?.inputBox.prependHistory(history);
219
- }
220
- clearHistory() {
221
- this.searchInput?.inputBox.clearHistory();
222
- this.replaceInput?.inputBox.clearHistory();
223
- }
224
- showNextSearchTerm() {
225
- this.searchInput?.inputBox.showNextValue();
226
- }
227
- showPreviousSearchTerm() {
228
- this.searchInput?.inputBox.showPreviousValue();
229
- }
230
- showNextReplaceTerm() {
231
- this.replaceInput?.inputBox.showNextValue();
232
- }
233
- showPreviousReplaceTerm() {
234
- this.replaceInput?.inputBox.showPreviousValue();
235
- }
236
- searchInputHasFocus() {
237
- return !!this.searchInputBoxFocused.get();
238
- }
239
- replaceInputHasFocus() {
240
- return !!this.replaceInput?.inputBox.hasFocus();
241
- }
242
- focusReplaceAllAction() {
243
- this.replaceActionBar?.focus(true);
244
- }
245
- focusRegexAction() {
246
- this.searchInput?.focusOnRegex();
247
- }
248
- render(container, options) {
249
- this.domNode = append(container, $('.search-widget'));
250
- this.domNode.style.position = 'relative';
251
- if (!options._hideReplaceToggle) {
252
- this.renderToggleReplaceButton(this.domNode);
253
- }
254
- this.renderSearchInput(this.domNode, options);
255
- this.renderReplaceInput(this.domNode, options);
256
- }
257
- updateAccessibilitySupport() {
258
- this.searchInput?.setFocusInputOnOptionClick(!this.accessibilityService.isScreenReaderOptimized());
259
- }
260
- renderToggleReplaceButton(parent) {
261
- const opts = {
262
- buttonBackground: undefined,
263
- buttonBorder: undefined,
264
- buttonForeground: undefined,
265
- buttonHoverBackground: undefined,
266
- buttonSecondaryBackground: undefined,
267
- buttonSecondaryForeground: undefined,
268
- buttonSecondaryHoverBackground: undefined,
269
- buttonSeparator: undefined
270
- };
271
- this.toggleReplaceButton = this._register(( new Button(parent, opts)));
272
- this.toggleReplaceButton.element.setAttribute('aria-expanded', 'false');
273
- this.toggleReplaceButton.element.classList.add('toggle-replace-button');
274
- this.toggleReplaceButton.icon = searchHideReplaceIcon;
275
- this.toggleReplaceButton.onDidClick(() => this.onToggleReplaceButton());
276
- this.toggleReplaceButton.element.title = ( localizeWithPath(
277
- 'vs/workbench/contrib/search/browser/searchWidget',
278
- 'search.replace.toggle.button.title',
279
- "Toggle Replace"
280
- ));
281
- }
282
- renderSearchInput(parent, options) {
283
- const inputOptions = {
284
- label: ( localizeWithPath(
285
- 'vs/workbench/contrib/search/browser/searchWidget',
286
- 'label.Search',
287
- 'Search: Type Search Term and press Enter to search'
288
- )),
289
- validation: (value) => this.validateSearchInput(value),
290
- placeholder: ( localizeWithPath(
291
- 'vs/workbench/contrib/search/browser/searchWidget',
292
- 'search.placeHolder',
293
- "Search"
294
- )),
295
- appendCaseSensitiveLabel: appendKeyBindingLabel('', this.keybindingService.lookupKeybinding("toggleSearchCaseSensitive" )),
296
- appendWholeWordsLabel: appendKeyBindingLabel('', this.keybindingService.lookupKeybinding("toggleSearchWholeWord" )),
297
- appendRegexLabel: appendKeyBindingLabel('', this.keybindingService.lookupKeybinding("toggleSearchRegex" )),
298
- history: options.searchHistory,
299
- showHistoryHint: () => showHistoryKeybindingHint(this.keybindingService),
300
- flexibleHeight: true,
301
- flexibleMaxHeight: SearchWidget_1.INPUT_MAX_HEIGHT,
302
- showCommonFindToggles: true,
303
- inputBoxStyles: options.inputBoxStyles,
304
- toggleStyles: options.toggleStyles
305
- };
306
- const searchInputContainer = append(parent, $('.search-container.input-box'));
307
- this.searchInput = this._register(( new SearchFindInput(
308
- searchInputContainer,
309
- this.contextViewService,
310
- inputOptions,
311
- this.contextKeyService,
312
- this.contextMenuService,
313
- this.instantiationService,
314
- this._notebookFilters,
315
- this._hasNotebookOpen()
316
- )));
317
- this.searchInput.onKeyDown((keyboardEvent) => this.onSearchInputKeyDown(keyboardEvent));
318
- this.searchInput.setValue(options.value || '');
319
- this.searchInput.setRegex(!!options.isRegex);
320
- this.searchInput.setCaseSensitive(!!options.isCaseSensitive);
321
- this.searchInput.setWholeWords(!!options.isWholeWords);
322
- this._register(this.searchInput.onCaseSensitiveKeyDown((keyboardEvent) => this.onCaseSensitiveKeyDown(keyboardEvent)));
323
- this._register(this.searchInput.onRegexKeyDown((keyboardEvent) => this.onRegexKeyDown(keyboardEvent)));
324
- this._register(this.searchInput.inputBox.onDidChange(() => this.onSearchInputChanged()));
325
- this._register(this.searchInput.inputBox.onDidHeightChange(() => this._onDidHeightChange.fire()));
326
- this._register(this.onReplaceValueChanged(() => {
327
- this._replaceHistoryDelayer.trigger(() => this.replaceInput?.inputBox.addToHistory());
328
- }));
329
- this.searchInputFocusTracker = this._register(trackFocus(this.searchInput.inputBox.inputElement));
330
- this._register(this.searchInputFocusTracker.onDidFocus(async () => {
331
- this.searchInputBoxFocused.set(true);
332
- const useGlobalFindBuffer = this.searchConfiguration.globalFindClipboard;
333
- if (!this.ignoreGlobalFindBufferOnNextFocus && useGlobalFindBuffer) {
334
- const globalBufferText = await this.clipboardServce.readFindText();
335
- if (globalBufferText && this.previousGlobalFindBufferValue !== globalBufferText) {
336
- this.searchInput?.inputBox.addToHistory();
337
- this.searchInput?.setValue(globalBufferText);
338
- this.searchInput?.select();
339
- }
340
- this.previousGlobalFindBufferValue = globalBufferText;
341
- }
342
- this.ignoreGlobalFindBufferOnNextFocus = false;
343
- }));
344
- this._register(this.searchInputFocusTracker.onDidBlur(() => this.searchInputBoxFocused.set(false)));
345
- this.showContextToggle = ( new Toggle({
346
- isChecked: false,
347
- title: appendKeyBindingLabel(( localizeWithPath(
348
- 'vs/workbench/contrib/search/browser/searchWidget',
349
- 'showContext',
350
- "Toggle Context Lines"
351
- )), this.keybindingService.lookupKeybinding(ToggleSearchEditorContextLinesCommandId)),
352
- icon: searchShowContextIcon,
353
- ...defaultToggleStyles
354
- }));
355
- this._register(this.showContextToggle.onChange(() => this.onContextLinesChanged()));
356
- if (options.showContextToggle) {
357
- this.contextLinesInput = ( new InputBox(
358
- searchInputContainer,
359
- this.contextViewService,
360
- { type: 'number', inputBoxStyles: defaultInputBoxStyles }
361
- ));
362
- this.contextLinesInput.element.classList.add('context-lines-input');
363
- this.contextLinesInput.value = '' + (this.configurationService.getValue('search').searchEditor.defaultNumberOfContextLines ?? 1);
364
- this._register(this.contextLinesInput.onDidChange((value) => {
365
- if (value !== '0') {
366
- this.showContextToggle.checked = true;
367
- }
368
- this.onContextLinesChanged();
369
- }));
370
- append(searchInputContainer, this.showContextToggle.domNode);
371
- }
372
- }
373
- onContextLinesChanged() {
374
- this._onDidToggleContext.fire();
375
- if (this.contextLinesInput.value.includes('-')) {
376
- this.contextLinesInput.value = '0';
377
- }
378
- this._onDidToggleContext.fire();
379
- }
380
- setContextLines(lines) {
381
- if (!this.contextLinesInput) {
382
- return;
383
- }
384
- if (lines === 0) {
385
- this.showContextToggle.checked = false;
386
- }
387
- else {
388
- this.showContextToggle.checked = true;
389
- this.contextLinesInput.value = '' + lines;
390
- }
391
- }
392
- renderReplaceInput(parent, options) {
393
- this.replaceContainer = append(parent, $('.replace-container.disabled'));
394
- const replaceBox = append(this.replaceContainer, $('.replace-input'));
395
- this.replaceInput = this._register(( new ContextScopedReplaceInput(replaceBox, this.contextViewService, {
396
- label: ( localizeWithPath(
397
- 'vs/workbench/contrib/search/browser/searchWidget',
398
- 'label.Replace',
399
- 'Replace: Type replace term and press Enter to preview'
400
- )),
401
- placeholder: ( localizeWithPath(
402
- 'vs/workbench/contrib/search/browser/searchWidget',
403
- 'search.replace.placeHolder',
404
- "Replace"
405
- )),
406
- appendPreserveCaseLabel: appendKeyBindingLabel('', this.keybindingService.lookupKeybinding("toggleSearchPreserveCase" )),
407
- history: options.replaceHistory,
408
- showHistoryHint: () => showHistoryKeybindingHint(this.keybindingService),
409
- flexibleHeight: true,
410
- flexibleMaxHeight: SearchWidget_1.INPUT_MAX_HEIGHT,
411
- inputBoxStyles: options.inputBoxStyles,
412
- toggleStyles: options.toggleStyles
413
- }, this.contextKeyService, true)));
414
- this._register(this.replaceInput.onDidOptionChange(viaKeyboard => {
415
- if (!viaKeyboard) {
416
- if (this.replaceInput) {
417
- this._onPreserveCaseChange.fire(this.replaceInput.getPreserveCase());
418
- }
419
- }
420
- }));
421
- this.replaceInput.onKeyDown((keyboardEvent) => this.onReplaceInputKeyDown(keyboardEvent));
422
- this.replaceInput.setValue(options.replaceValue || '');
423
- this._register(this.replaceInput.inputBox.onDidChange(() => this._onReplaceValueChanged.fire()));
424
- this._register(this.replaceInput.inputBox.onDidHeightChange(() => this._onDidHeightChange.fire()));
425
- this.replaceAllAction = ( new ReplaceAllAction(this));
426
- this.replaceAllAction.label = SearchWidget_1.REPLACE_ALL_DISABLED_LABEL;
427
- this.replaceActionBar = this._register(( new ActionBar(this.replaceContainer)));
428
- this.replaceActionBar.push([this.replaceAllAction], { icon: true, label: false });
429
- this.onkeydown(this.replaceActionBar.domNode, (keyboardEvent) => this.onReplaceActionbarKeyDown(keyboardEvent));
430
- this.replaceInputFocusTracker = this._register(trackFocus(this.replaceInput.inputBox.inputElement));
431
- this._register(this.replaceInputFocusTracker.onDidFocus(() => this.replaceInputBoxFocused.set(true)));
432
- this._register(this.replaceInputFocusTracker.onDidBlur(() => this.replaceInputBoxFocused.set(false)));
433
- this._register(this.replaceInput.onPreserveCaseKeyDown((keyboardEvent) => this.onPreserveCaseKeyDown(keyboardEvent)));
434
- }
435
- triggerReplaceAll() {
436
- this._onReplaceAll.fire();
437
- return Promise.resolve(null);
438
- }
439
- onToggleReplaceButton() {
440
- this.replaceContainer?.classList.toggle('disabled');
441
- if (this.isReplaceShown()) {
442
- this.toggleReplaceButton?.element.classList.remove(...ThemeIcon.asClassNameArray(searchHideReplaceIcon));
443
- this.toggleReplaceButton?.element.classList.add(...ThemeIcon.asClassNameArray(searchShowReplaceIcon));
444
- }
445
- else {
446
- this.toggleReplaceButton?.element.classList.remove(...ThemeIcon.asClassNameArray(searchShowReplaceIcon));
447
- this.toggleReplaceButton?.element.classList.add(...ThemeIcon.asClassNameArray(searchHideReplaceIcon));
448
- }
449
- this.toggleReplaceButton?.element.setAttribute('aria-expanded', this.isReplaceShown() ? 'true' : 'false');
450
- this.updateReplaceActiveState();
451
- this._onReplaceToggled.fire();
452
- }
453
- setValue(value) {
454
- this.searchInput?.setValue(value);
455
- }
456
- setReplaceAllActionState(enabled) {
457
- if (this.replaceAllAction && (this.replaceAllAction.enabled !== enabled)) {
458
- this.replaceAllAction.enabled = enabled;
459
- this.replaceAllAction.label = enabled ? SearchWidget_1.REPLACE_ALL_ENABLED_LABEL(this.keybindingService) : SearchWidget_1.REPLACE_ALL_DISABLED_LABEL;
460
- this.updateReplaceActiveState();
461
- }
462
- }
463
- updateReplaceActiveState() {
464
- const currentState = this.isReplaceActive();
465
- const newState = this.isReplaceShown() && !!this.replaceAllAction?.enabled;
466
- if (currentState !== newState) {
467
- this.replaceActive.set(newState);
468
- this._onReplaceStateChange.fire(newState);
469
- this.replaceInput?.inputBox.layout();
470
- }
471
- }
472
- validateSearchInput(value) {
473
- if (value.length === 0) {
474
- return null;
475
- }
476
- if (!(this.searchInput?.getRegex())) {
477
- return null;
478
- }
479
- return null;
480
- }
481
- onSearchInputChanged() {
482
- this.searchInput?.clearMessage();
483
- this.setReplaceAllActionState(false);
484
- if (this.searchConfiguration.searchOnType) {
485
- if (this.searchInput?.getRegex()) {
486
- try {
487
- const regex = ( new RegExp(this.searchInput.getValue(), 'ug'));
488
- const matchienessHeuristic = `
489
- ~!@#$%^&*()_+
490
- \`1234567890-=
491
- qwertyuiop[]\\
492
- QWERTYUIOP{}|
493
- asdfghjkl;'
494
- ASDFGHJKL:"
495
- zxcvbnm,./
496
- ZXCVBNM<>? `.match(regex)?.length ?? 0;
497
- const delayMultiplier = matchienessHeuristic < 50 ? 1 :
498
- matchienessHeuristic < 100 ? 5 :
499
- 10;
500
- this.submitSearch(true, this.searchConfiguration.searchOnTypeDebouncePeriod * delayMultiplier);
501
- }
502
- catch {
503
- }
504
- }
505
- else {
506
- this.submitSearch(true, this.searchConfiguration.searchOnTypeDebouncePeriod);
507
- }
508
- }
509
- }
510
- onSearchInputKeyDown(keyboardEvent) {
511
- if (keyboardEvent.equals(ctrlKeyMod | 3 )) {
512
- this.searchInput?.inputBox.insertAtCursor('\n');
513
- keyboardEvent.preventDefault();
514
- }
515
- if (keyboardEvent.equals(3 )) {
516
- this.searchInput?.onSearchSubmit();
517
- this.submitSearch();
518
- keyboardEvent.preventDefault();
519
- }
520
- else if (keyboardEvent.equals(9 )) {
521
- this._onSearchCancel.fire({ focus: true });
522
- keyboardEvent.preventDefault();
523
- }
524
- else if (keyboardEvent.equals(2 )) {
525
- if (this.isReplaceShown()) {
526
- this.replaceInput?.focus();
527
- }
528
- else {
529
- this.searchInput?.focusOnCaseSensitive();
530
- }
531
- keyboardEvent.preventDefault();
532
- }
533
- else if (keyboardEvent.equals(16 )) {
534
- stopPropagationForMultiLineUpwards(keyboardEvent, this.searchInput?.getValue() ?? '', this.searchInput?.domNode.querySelector('textarea') ?? null);
535
- }
536
- else if (keyboardEvent.equals(18 )) {
537
- stopPropagationForMultiLineDownwards(keyboardEvent, this.searchInput?.getValue() ?? '', this.searchInput?.domNode.querySelector('textarea') ?? null);
538
- }
539
- }
540
- onCaseSensitiveKeyDown(keyboardEvent) {
541
- if (keyboardEvent.equals(1024 | 2 )) {
542
- if (this.isReplaceShown()) {
543
- this.replaceInput?.focus();
544
- keyboardEvent.preventDefault();
545
- }
546
- }
547
- }
548
- onRegexKeyDown(keyboardEvent) {
549
- if (keyboardEvent.equals(2 )) {
550
- if (this.isReplaceShown()) {
551
- this.replaceInput?.focusOnPreserve();
552
- keyboardEvent.preventDefault();
553
- }
554
- }
555
- }
556
- onPreserveCaseKeyDown(keyboardEvent) {
557
- if (keyboardEvent.equals(2 )) {
558
- if (this.isReplaceActive()) {
559
- this.focusReplaceAllAction();
560
- }
561
- else {
562
- this._onBlur.fire();
563
- }
564
- keyboardEvent.preventDefault();
565
- }
566
- else if (keyboardEvent.equals(1024 | 2 )) {
567
- this.focusRegexAction();
568
- keyboardEvent.preventDefault();
569
- }
570
- }
571
- onReplaceInputKeyDown(keyboardEvent) {
572
- if (keyboardEvent.equals(ctrlKeyMod | 3 )) {
573
- this.replaceInput?.inputBox.insertAtCursor('\n');
574
- keyboardEvent.preventDefault();
575
- }
576
- if (keyboardEvent.equals(3 )) {
577
- this.submitSearch();
578
- keyboardEvent.preventDefault();
579
- }
580
- else if (keyboardEvent.equals(2 )) {
581
- this.searchInput?.focusOnCaseSensitive();
582
- keyboardEvent.preventDefault();
583
- }
584
- else if (keyboardEvent.equals(1024 | 2 )) {
585
- this.searchInput?.focus();
586
- keyboardEvent.preventDefault();
587
- }
588
- else if (keyboardEvent.equals(16 )) {
589
- stopPropagationForMultiLineUpwards(keyboardEvent, this.replaceInput?.getValue() ?? '', this.replaceInput?.domNode.querySelector('textarea') ?? null);
590
- }
591
- else if (keyboardEvent.equals(18 )) {
592
- stopPropagationForMultiLineDownwards(keyboardEvent, this.replaceInput?.getValue() ?? '', this.replaceInput?.domNode.querySelector('textarea') ?? null);
593
- }
594
- }
595
- onReplaceActionbarKeyDown(keyboardEvent) {
596
- if (keyboardEvent.equals(1024 | 2 )) {
597
- this.focusRegexAction();
598
- keyboardEvent.preventDefault();
599
- }
600
- }
601
- async submitSearch(triggeredOnType = false, delay = 0) {
602
- this.searchInput?.validate();
603
- if (!this.searchInput?.inputBox.isInputValid()) {
604
- return;
605
- }
606
- const value = this.searchInput.getValue();
607
- const useGlobalFindBuffer = this.searchConfiguration.globalFindClipboard;
608
- if (value && useGlobalFindBuffer) {
609
- await this.clipboardServce.writeFindText(value);
610
- }
611
- this._onSearchSubmit.fire({ triggeredOnType, delay });
612
- }
613
- getContextLines() {
614
- return this.showContextToggle.checked ? +this.contextLinesInput.value : 0;
615
- }
616
- modifyContextLines(increase) {
617
- const current = +this.contextLinesInput.value;
618
- const modified = current + (increase ? 1 : -1);
619
- this.showContextToggle.checked = modified !== 0;
620
- this.contextLinesInput.value = '' + modified;
621
- }
622
- toggleContextLines() {
623
- this.showContextToggle.checked = !this.showContextToggle.checked;
624
- this.onContextLinesChanged();
625
- }
626
- dispose() {
627
- this.setReplaceAllActionState(false);
628
- super.dispose();
629
- }
630
- get searchConfiguration() {
631
- return this.configurationService.getValue('search');
632
- }
633
- };
634
- SearchWidget = SearchWidget_1 = ( __decorate([
635
- ( __param(2, IContextViewService)),
636
- ( __param(3, IContextKeyService)),
637
- ( __param(4, IKeybindingService)),
638
- ( __param(5, IClipboardService)),
639
- ( __param(6, IConfigurationService)),
640
- ( __param(7, IAccessibilityService)),
641
- ( __param(8, IContextMenuService)),
642
- ( __param(9, IInstantiationService)),
643
- ( __param(10, IEditorService))
644
- ], SearchWidget));
645
- function registerContributions() {
646
- KeybindingsRegistry.registerCommandAndKeybindingRule({
647
- id: ReplaceAllAction.ID,
648
- weight: 200 ,
649
- when: ( ContextKeyExpr.and(
650
- SearchContext.SearchViewVisibleKey,
651
- SearchContext.ReplaceActiveKey,
652
- CONTEXT_FIND_WIDGET_NOT_VISIBLE
653
- )),
654
- primary: 512 | 2048 | 3 ,
655
- handler: accessor => {
656
- const viewsService = accessor.get(IViewsService);
657
- if (isSearchViewFocused(viewsService)) {
658
- const searchView = getSearchView(viewsService);
659
- if (searchView) {
660
- ( new ReplaceAllAction(searchView.searchAndReplaceWidget)).run();
661
- }
662
- }
663
- }
664
- });
665
- }
666
-
667
- export { SearchWidget, registerContributions };