@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,736 +0,0 @@
1
- import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
2
- import { $, append, addDisposableListener, EventType, EventHelper, clearNode, getTotalHeight } from 'vscode/vscode/vs/base/browser/dom';
3
- import { StandardKeyboardEvent } from 'vscode/vscode/vs/base/browser/keyboardEvent';
4
- import { alert } from 'vscode/vscode/vs/base/browser/ui/aria/aria';
5
- import { Delayer } from 'vscode/vscode/vs/base/common/async';
6
- import { DisposableStore } from 'vscode/vscode/vs/base/common/lifecycle';
7
- import { assertIsDefined } from 'vscode/vscode/vs/base/common/types';
8
- import './media/searchEditor.css.js';
9
- import { Position } from 'vscode/vscode/vs/editor/common/core/position';
10
- import { Range } from 'vscode/vscode/vs/editor/common/core/range';
11
- import { Selection } from 'vscode/vscode/vs/editor/common/core/selection';
12
- import { IModelService } from 'vscode/vscode/vs/editor/common/services/model';
13
- import { ITextResourceConfigurationService } from 'vscode/vscode/vs/editor/common/services/textResourceConfiguration';
14
- import { ReferencesController } from 'vscode/vscode/vs/editor/contrib/gotoSymbol/browser/peek/referencesController';
15
- import { localizeWithPath } from 'vscode/vscode/vs/nls';
16
- import { ICommandService } from 'vscode/vscode/vs/platform/commands/common/commands';
17
- import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration';
18
- import { IContextKeyService } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
19
- import { IContextViewService } from 'vscode/vscode/vs/platform/contextview/browser/contextView';
20
- import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
21
- import { ServiceCollection } from 'vscode/vscode/vs/platform/instantiation/common/serviceCollection';
22
- import { ILabelService } from 'vscode/vscode/vs/platform/label/common/label';
23
- import { LongRunningOperation, IEditorProgressService } from 'vscode/vscode/vs/platform/progress/common/progress';
24
- import { IStorageService } from 'vscode/vscode/vs/platform/storage/common/storage';
25
- import { ITelemetryService } from 'vscode/vscode/vs/platform/telemetry/common/telemetry';
26
- import { registerColor, inputBorder } from 'vscode/vscode/vs/platform/theme/common/colorRegistry';
27
- import { IThemeService } from 'vscode/vscode/vs/platform/theme/common/themeService';
28
- import { ThemeIcon } from 'vscode/vscode/vs/base/common/themables';
29
- import { IWorkspaceContextService } from 'vscode/vscode/vs/platform/workspace/common/workspace';
30
- import { AbstractTextCodeEditor } from 'vscode/vscode/vs/workbench/browser/parts/editor/textCodeEditor';
31
- import { IncludePatternInputWidget, ExcludePatternInputWidget } from '../../search/browser/patternInputWidget.js';
32
- import { SearchWidget } from '../../search/browser/searchWidget.js';
33
- import { QueryBuilder } from 'vscode/vscode/vs/workbench/services/search/common/queryBuilder';
34
- import { getOutOfWorkspaceEditorResources } from 'vscode/vscode/vs/workbench/contrib/search/common/search';
35
- import { SearchModel } from 'vscode/vscode/vs/workbench/contrib/search/browser/searchModel';
36
- import { SearchEditorID, InSearchEditor, SearchEditorInputTypeId } from 'vscode/vscode/vs/workbench/contrib/searchEditor/browser/constants';
37
- import { serializeSearchResultForEditor } from './searchEditorSerialization.js';
38
- import { IEditorGroupsService } from 'vscode/vscode/vs/workbench/services/editor/common/editorGroupsService';
39
- import { IEditorService } from 'vscode/vscode/vs/workbench/services/editor/common/editorService';
40
- import { searchDetailsIcon } from '../../search/browser/searchIcons.js';
41
- import { IFileService } from 'vscode/vscode/vs/platform/files/common/files';
42
- import { IOpenerService } from 'vscode/vscode/vs/platform/opener/common/opener';
43
- import { INotificationService } from 'vscode/vscode/vs/platform/notification/common/notification';
44
- import { renderSearchMessage } from '../../search/browser/searchMessage.js';
45
- import { EditorExtensionsRegistry } from 'vscode/vscode/vs/editor/browser/editorExtensions';
46
- import { UnusualLineTerminatorsDetector } from 'vscode/vscode/vs/editor/contrib/unusualLineTerminators/browser/unusualLineTerminators';
47
- import { getInputBoxStyle, defaultToggleStyles } from 'vscode/vscode/vs/platform/theme/browser/defaultStyles';
48
- import { ILogService } from 'vscode/vscode/vs/platform/log/common/log';
49
- import { SearchContext } from 'vscode/vscode/vs/workbench/contrib/search/common/constants';
50
-
51
- var SearchEditor_1;
52
- const RESULT_LINE_REGEX = /^(\s+)(\d+)(: | )(\s*)(.*)$/;
53
- const FILE_LINE_REGEX = /^(\S.*):$/;
54
- let SearchEditor = class SearchEditor extends AbstractTextCodeEditor {
55
- static { SearchEditor_1 = this; }
56
- static { this.ID = SearchEditorID; }
57
- static { this.SEARCH_EDITOR_VIEW_STATE_PREFERENCE_KEY = 'searchEditorViewState'; }
58
- get searchResultEditor() { return this.editorControl; }
59
- constructor(telemetryService, themeService, storageService, modelService, contextService, labelService, instantiationService, contextViewService, commandService, openerService, notificationService, progressService, textResourceService, editorGroupService, editorService, configurationService, fileService, logService) {
60
- super(SearchEditor_1.ID, telemetryService, instantiationService, storageService, textResourceService, themeService, editorService, editorGroupService, fileService);
61
- this.modelService = modelService;
62
- this.contextService = contextService;
63
- this.labelService = labelService;
64
- this.contextViewService = contextViewService;
65
- this.commandService = commandService;
66
- this.openerService = openerService;
67
- this.notificationService = notificationService;
68
- this.configurationService = configurationService;
69
- this.logService = logService;
70
- this.runSearchDelayer = ( new Delayer(0));
71
- this.pauseSearching = false;
72
- this.showingIncludesExcludes = false;
73
- this.ongoingOperations = 0;
74
- this.updatingModelForSearch = false;
75
- this.container = $('.search-editor');
76
- this.searchOperation = this._register(( new LongRunningOperation(progressService)));
77
- this._register(this.messageDisposables = ( new DisposableStore()));
78
- this.searchHistoryDelayer = ( new Delayer(2000));
79
- this.searchModel = this._register(this.instantiationService.createInstance(SearchModel));
80
- }
81
- createEditor(parent) {
82
- append(parent, this.container);
83
- this.queryEditorContainer = append(this.container, $('.query-container'));
84
- const searchResultContainer = append(this.container, $('.search-results'));
85
- super.createEditor(searchResultContainer);
86
- this.registerEditorListeners();
87
- const scopedContextKeyService = assertIsDefined(this.scopedContextKeyService);
88
- InSearchEditor.bindTo(scopedContextKeyService).set(true);
89
- this.createQueryEditor(this.queryEditorContainer, this.instantiationService.createChild(( new ServiceCollection([IContextKeyService, scopedContextKeyService]))), SearchContext.InputBoxFocusedKey.bindTo(scopedContextKeyService));
90
- }
91
- createQueryEditor(container, scopedInstantiationService, inputBoxFocusedContextKey) {
92
- const searchEditorInputboxStyles = getInputBoxStyle({ inputBorder: searchEditorTextInputBorder });
93
- this.queryEditorWidget = this._register(scopedInstantiationService.createInstance(SearchWidget, container, { _hideReplaceToggle: true, showContextToggle: true, inputBoxStyles: searchEditorInputboxStyles, toggleStyles: defaultToggleStyles }));
94
- this._register(this.queryEditorWidget.onReplaceToggled(() => this.reLayout()));
95
- this._register(this.queryEditorWidget.onDidHeightChange(() => this.reLayout()));
96
- this._register(this.queryEditorWidget.onSearchSubmit(({ delay }) => this.triggerSearch({ delay })));
97
- if (this.queryEditorWidget.searchInput) {
98
- this._register(this.queryEditorWidget.searchInput.onDidOptionChange(() => this.triggerSearch({ resetCursor: false })));
99
- }
100
- else {
101
- this.logService.warn('SearchEditor: SearchWidget.searchInput is undefined, cannot register onDidOptionChange listener');
102
- }
103
- this._register(this.queryEditorWidget.onDidToggleContext(() => this.triggerSearch({ resetCursor: false })));
104
- this.includesExcludesContainer = append(container, $('.includes-excludes'));
105
- this.toggleQueryDetailsButton = append(this.includesExcludesContainer, $('.expand' + ThemeIcon.asCSSSelector(searchDetailsIcon), { tabindex: 0, role: 'button', title: ( localizeWithPath(
106
- 'vs/workbench/contrib/searchEditor/browser/searchEditor',
107
- 'moreSearch',
108
- "Toggle Search Details"
109
- )) }));
110
- this._register(addDisposableListener(this.toggleQueryDetailsButton, EventType.CLICK, e => {
111
- EventHelper.stop(e);
112
- this.toggleIncludesExcludes();
113
- }));
114
- this._register(addDisposableListener(this.toggleQueryDetailsButton, EventType.KEY_UP, (e) => {
115
- const event = ( new StandardKeyboardEvent(e));
116
- if (event.equals(3 ) || event.equals(10 )) {
117
- EventHelper.stop(e);
118
- this.toggleIncludesExcludes();
119
- }
120
- }));
121
- this._register(addDisposableListener(this.toggleQueryDetailsButton, EventType.KEY_DOWN, (e) => {
122
- const event = ( new StandardKeyboardEvent(e));
123
- if (event.equals(1024 | 2 )) {
124
- if (this.queryEditorWidget.isReplaceActive()) {
125
- this.queryEditorWidget.focusReplaceAllAction();
126
- }
127
- else {
128
- this.queryEditorWidget.isReplaceShown() ? this.queryEditorWidget.replaceInput?.focusOnPreserve() : this.queryEditorWidget.focusRegexAction();
129
- }
130
- EventHelper.stop(e);
131
- }
132
- }));
133
- const folderIncludesList = append(this.includesExcludesContainer, $('.file-types.includes'));
134
- const filesToIncludeTitle = ( localizeWithPath(
135
- 'vs/workbench/contrib/searchEditor/browser/searchEditor',
136
- 'searchScope.includes',
137
- "files to include"
138
- ));
139
- append(folderIncludesList, $('h4', undefined, filesToIncludeTitle));
140
- this.inputPatternIncludes = this._register(scopedInstantiationService.createInstance(IncludePatternInputWidget, folderIncludesList, this.contextViewService, {
141
- ariaLabel: ( localizeWithPath(
142
- 'vs/workbench/contrib/searchEditor/browser/searchEditor',
143
- 'label.includes',
144
- 'Search Include Patterns'
145
- )),
146
- inputBoxStyles: searchEditorInputboxStyles
147
- }));
148
- this.inputPatternIncludes.onSubmit(triggeredOnType => this.triggerSearch({ resetCursor: false, delay: triggeredOnType ? this.searchConfig.searchOnTypeDebouncePeriod : 0 }));
149
- this._register(this.inputPatternIncludes.onChangeSearchInEditorsBox(() => this.triggerSearch()));
150
- const excludesList = append(this.includesExcludesContainer, $('.file-types.excludes'));
151
- const excludesTitle = ( localizeWithPath(
152
- 'vs/workbench/contrib/searchEditor/browser/searchEditor',
153
- 'searchScope.excludes',
154
- "files to exclude"
155
- ));
156
- append(excludesList, $('h4', undefined, excludesTitle));
157
- this.inputPatternExcludes = this._register(scopedInstantiationService.createInstance(ExcludePatternInputWidget, excludesList, this.contextViewService, {
158
- ariaLabel: ( localizeWithPath(
159
- 'vs/workbench/contrib/searchEditor/browser/searchEditor',
160
- 'label.excludes',
161
- 'Search Exclude Patterns'
162
- )),
163
- inputBoxStyles: searchEditorInputboxStyles
164
- }));
165
- this.inputPatternExcludes.onSubmit(triggeredOnType => this.triggerSearch({ resetCursor: false, delay: triggeredOnType ? this.searchConfig.searchOnTypeDebouncePeriod : 0 }));
166
- this._register(this.inputPatternExcludes.onChangeIgnoreBox(() => this.triggerSearch()));
167
- this.messageBox = append(container, $('.messages.text-search-provider-messages'));
168
- [this.queryEditorWidget.searchInputFocusTracker, this.queryEditorWidget.replaceInputFocusTracker, this.inputPatternExcludes.inputFocusTracker, this.inputPatternIncludes.inputFocusTracker]
169
- .forEach(tracker => {
170
- if (!tracker) {
171
- return;
172
- }
173
- this._register(tracker.onDidFocus(() => setTimeout(() => inputBoxFocusedContextKey.set(true), 0)));
174
- this._register(tracker.onDidBlur(() => inputBoxFocusedContextKey.set(false)));
175
- });
176
- }
177
- toggleRunAgainMessage(show) {
178
- clearNode(this.messageBox);
179
- this.messageDisposables.clear();
180
- if (show) {
181
- const runAgainLink = append(this.messageBox, $('a.pointer.prominent.message', {}, ( localizeWithPath(
182
- 'vs/workbench/contrib/searchEditor/browser/searchEditor',
183
- 'runSearch',
184
- "Run Search"
185
- ))));
186
- this.messageDisposables.add(addDisposableListener(runAgainLink, EventType.CLICK, async () => {
187
- await this.triggerSearch();
188
- this.searchResultEditor.focus();
189
- }));
190
- }
191
- }
192
- _getContributions() {
193
- const skipContributions = [UnusualLineTerminatorsDetector.ID];
194
- return EditorExtensionsRegistry.getEditorContributions().filter(c => skipContributions.indexOf(c.id) === -1);
195
- }
196
- getCodeEditorWidgetOptions() {
197
- return { contributions: this._getContributions() };
198
- }
199
- registerEditorListeners() {
200
- this.searchResultEditor.onMouseUp(e => {
201
- if (e.event.detail === 2) {
202
- const behaviour = this.searchConfig.searchEditor.doubleClickBehaviour;
203
- const position = e.target.position;
204
- if (position && behaviour !== 'selectWord') {
205
- const line = this.searchResultEditor.getModel()?.getLineContent(position.lineNumber) ?? '';
206
- if (line.match(RESULT_LINE_REGEX)) {
207
- this.searchResultEditor.setSelection(Range.fromPositions(position));
208
- this.commandService.executeCommand(behaviour === 'goToLocation' ? 'editor.action.goToDeclaration' : 'editor.action.openDeclarationToTheSide');
209
- }
210
- else if (line.match(FILE_LINE_REGEX)) {
211
- this.searchResultEditor.setSelection(Range.fromPositions(position));
212
- this.commandService.executeCommand('editor.action.peekDefinition');
213
- }
214
- }
215
- }
216
- });
217
- this._register(this.searchResultEditor.onDidChangeModelContent(() => {
218
- if (!this.updatingModelForSearch) {
219
- this.getInput()?.setDirty(true);
220
- }
221
- }));
222
- }
223
- getControl() {
224
- return this.searchResultEditor;
225
- }
226
- focus() {
227
- super.focus();
228
- const viewState = this.loadEditorViewState(this.getInput());
229
- if (viewState && viewState.focused === 'editor') {
230
- this.searchResultEditor.focus();
231
- }
232
- else {
233
- this.queryEditorWidget.focus();
234
- }
235
- }
236
- focusSearchInput() {
237
- this.queryEditorWidget.searchInput?.focus();
238
- }
239
- focusFilesToIncludeInput() {
240
- if (!this.showingIncludesExcludes) {
241
- this.toggleIncludesExcludes(true);
242
- }
243
- this.inputPatternIncludes.focus();
244
- }
245
- focusFilesToExcludeInput() {
246
- if (!this.showingIncludesExcludes) {
247
- this.toggleIncludesExcludes(true);
248
- }
249
- this.inputPatternExcludes.focus();
250
- }
251
- focusNextInput() {
252
- if (this.queryEditorWidget.searchInputHasFocus()) {
253
- if (this.showingIncludesExcludes) {
254
- this.inputPatternIncludes.focus();
255
- }
256
- else {
257
- this.searchResultEditor.focus();
258
- }
259
- }
260
- else if (this.inputPatternIncludes.inputHasFocus()) {
261
- this.inputPatternExcludes.focus();
262
- }
263
- else if (this.inputPatternExcludes.inputHasFocus()) {
264
- this.searchResultEditor.focus();
265
- }
266
- else if (this.searchResultEditor.hasWidgetFocus()) ;
267
- }
268
- focusPrevInput() {
269
- if (this.queryEditorWidget.searchInputHasFocus()) {
270
- this.searchResultEditor.focus();
271
- }
272
- else if (this.inputPatternIncludes.inputHasFocus()) {
273
- this.queryEditorWidget.searchInput?.focus();
274
- }
275
- else if (this.inputPatternExcludes.inputHasFocus()) {
276
- this.inputPatternIncludes.focus();
277
- }
278
- else if (this.searchResultEditor.hasWidgetFocus()) ;
279
- }
280
- setQuery(query) {
281
- this.queryEditorWidget.searchInput?.setValue(query);
282
- }
283
- selectQuery() {
284
- this.queryEditorWidget.searchInput?.select();
285
- }
286
- toggleWholeWords() {
287
- this.queryEditorWidget.searchInput?.setWholeWords(!this.queryEditorWidget.searchInput.getWholeWords());
288
- this.triggerSearch({ resetCursor: false });
289
- }
290
- toggleRegex() {
291
- this.queryEditorWidget.searchInput?.setRegex(!this.queryEditorWidget.searchInput.getRegex());
292
- this.triggerSearch({ resetCursor: false });
293
- }
294
- toggleCaseSensitive() {
295
- this.queryEditorWidget.searchInput?.setCaseSensitive(!this.queryEditorWidget.searchInput.getCaseSensitive());
296
- this.triggerSearch({ resetCursor: false });
297
- }
298
- toggleContextLines() {
299
- this.queryEditorWidget.toggleContextLines();
300
- }
301
- modifyContextLines(increase) {
302
- this.queryEditorWidget.modifyContextLines(increase);
303
- }
304
- toggleQueryDetails(shouldShow) {
305
- this.toggleIncludesExcludes(shouldShow);
306
- }
307
- deleteResultBlock() {
308
- const linesToDelete = ( new Set());
309
- const selections = this.searchResultEditor.getSelections();
310
- const model = this.searchResultEditor.getModel();
311
- if (!(selections && model)) {
312
- return;
313
- }
314
- const maxLine = model.getLineCount();
315
- const minLine = 1;
316
- const deleteUp = (start) => {
317
- for (let cursor = start; cursor >= minLine; cursor--) {
318
- const line = model.getLineContent(cursor);
319
- linesToDelete.add(cursor);
320
- if (line[0] !== undefined && line[0] !== ' ') {
321
- break;
322
- }
323
- }
324
- };
325
- const deleteDown = (start) => {
326
- linesToDelete.add(start);
327
- for (let cursor = start + 1; cursor <= maxLine; cursor++) {
328
- const line = model.getLineContent(cursor);
329
- if (line[0] !== undefined && line[0] !== ' ') {
330
- return cursor;
331
- }
332
- linesToDelete.add(cursor);
333
- }
334
- return;
335
- };
336
- const endingCursorLines = [];
337
- for (const selection of selections) {
338
- const lineNumber = selection.startLineNumber;
339
- endingCursorLines.push(deleteDown(lineNumber));
340
- deleteUp(lineNumber);
341
- for (let inner = selection.startLineNumber; inner <= selection.endLineNumber; inner++) {
342
- linesToDelete.add(inner);
343
- }
344
- }
345
- if (endingCursorLines.length === 0) {
346
- endingCursorLines.push(1);
347
- }
348
- const isDefined = (x) => x !== undefined;
349
- model.pushEditOperations(this.searchResultEditor.getSelections(), ( [...linesToDelete].map(line => ({ range: ( new Range(line, 1, line + 1, 1)), text: '' }))), () => ( endingCursorLines.filter(isDefined).map(line => ( new Selection(line, 1, line, 1)))));
350
- }
351
- cleanState() {
352
- this.getInput()?.setDirty(false);
353
- }
354
- get searchConfig() {
355
- return this.configurationService.getValue('search');
356
- }
357
- iterateThroughMatches(reverse) {
358
- const model = this.searchResultEditor.getModel();
359
- if (!model) {
360
- return;
361
- }
362
- const lastLine = model.getLineCount() ?? 1;
363
- const lastColumn = model.getLineLength(lastLine);
364
- const fallbackStart = reverse ? ( new Position(lastLine, lastColumn)) : ( new Position(1, 1));
365
- const currentPosition = this.searchResultEditor.getSelection()?.getStartPosition() ?? fallbackStart;
366
- const matchRanges = this.getInput()?.getMatchRanges();
367
- if (!matchRanges) {
368
- return;
369
- }
370
- const matchRange = (reverse ? findPrevRange : findNextRange)(matchRanges, currentPosition);
371
- this.searchResultEditor.setSelection(matchRange);
372
- this.searchResultEditor.revealLineInCenterIfOutsideViewport(matchRange.startLineNumber);
373
- this.searchResultEditor.focus();
374
- const matchLineText = model.getLineContent(matchRange.startLineNumber);
375
- const matchText = model.getValueInRange(matchRange);
376
- let file = '';
377
- for (let line = matchRange.startLineNumber; line >= 1; line--) {
378
- const lineText = model.getValueInRange(( new Range(line, 1, line, 2)));
379
- if (lineText !== ' ') {
380
- file = model.getLineContent(line);
381
- break;
382
- }
383
- }
384
- alert(( localizeWithPath(
385
- 'vs/workbench/contrib/searchEditor/browser/searchEditor',
386
- 'searchResultItem',
387
- "Matched {0} at {1} in file {2}",
388
- matchText,
389
- matchLineText,
390
- file.slice(0, file.length - 1)
391
- )));
392
- }
393
- focusNextResult() {
394
- this.iterateThroughMatches(false);
395
- }
396
- focusPreviousResult() {
397
- this.iterateThroughMatches(true);
398
- }
399
- focusAllResults() {
400
- this.searchResultEditor
401
- .setSelections(( (this.getInput()?.getMatchRanges() ?? []).map(range => ( new Selection(
402
- range.startLineNumber,
403
- range.startColumn,
404
- range.endLineNumber,
405
- range.endColumn
406
- )))));
407
- this.searchResultEditor.focus();
408
- }
409
- async triggerSearch(_options) {
410
- const options = { resetCursor: true, delay: 0, ..._options };
411
- if (!this.pauseSearching) {
412
- await this.runSearchDelayer.trigger(async () => {
413
- this.toggleRunAgainMessage(false);
414
- await this.doRunSearch();
415
- if (options.resetCursor) {
416
- this.searchResultEditor.setPosition(( new Position(1, 1)));
417
- this.searchResultEditor.setScrollPosition({ scrollTop: 0, scrollLeft: 0 });
418
- }
419
- if (options.focusResults) {
420
- this.searchResultEditor.focus();
421
- }
422
- }, options.delay);
423
- }
424
- }
425
- readConfigFromWidget() {
426
- return {
427
- isCaseSensitive: this.queryEditorWidget.searchInput?.getCaseSensitive() ?? false,
428
- contextLines: this.queryEditorWidget.getContextLines(),
429
- filesToExclude: this.inputPatternExcludes.getValue(),
430
- filesToInclude: this.inputPatternIncludes.getValue(),
431
- query: this.queryEditorWidget.searchInput?.getValue() ?? '',
432
- isRegexp: this.queryEditorWidget.searchInput?.getRegex() ?? false,
433
- matchWholeWord: this.queryEditorWidget.searchInput?.getWholeWords() ?? false,
434
- useExcludeSettingsAndIgnoreFiles: this.inputPatternExcludes.useExcludesAndIgnoreFiles(),
435
- onlyOpenEditors: this.inputPatternIncludes.onlySearchInOpenEditors(),
436
- showIncludesExcludes: this.showingIncludesExcludes,
437
- notebookSearchConfig: {
438
- includeMarkupInput: this.queryEditorWidget.getNotebookFilters().markupInput,
439
- includeMarkupPreview: this.queryEditorWidget.getNotebookFilters().markupPreview,
440
- includeCodeInput: this.queryEditorWidget.getNotebookFilters().codeInput,
441
- includeOutput: this.queryEditorWidget.getNotebookFilters().codeOutput,
442
- }
443
- };
444
- }
445
- async doRunSearch() {
446
- this.searchModel.cancelSearch(true);
447
- const startInput = this.getInput();
448
- if (!startInput) {
449
- return;
450
- }
451
- this.searchHistoryDelayer.trigger(() => {
452
- this.queryEditorWidget.searchInput?.onSearchSubmit();
453
- this.inputPatternExcludes.onSearchSubmit();
454
- this.inputPatternIncludes.onSearchSubmit();
455
- });
456
- const config = this.readConfigFromWidget();
457
- if (!config.query) {
458
- return;
459
- }
460
- const content = {
461
- pattern: config.query,
462
- isRegExp: config.isRegexp,
463
- isCaseSensitive: config.isCaseSensitive,
464
- isWordMatch: config.matchWholeWord,
465
- };
466
- const options = {
467
- _reason: 'searchEditor',
468
- extraFileResources: this.instantiationService.invokeFunction(getOutOfWorkspaceEditorResources),
469
- maxResults: this.searchConfig.maxResults ?? undefined,
470
- disregardIgnoreFiles: !config.useExcludeSettingsAndIgnoreFiles || undefined,
471
- disregardExcludeSettings: !config.useExcludeSettingsAndIgnoreFiles || undefined,
472
- excludePattern: config.filesToExclude,
473
- includePattern: config.filesToInclude,
474
- onlyOpenEditors: config.onlyOpenEditors,
475
- previewOptions: {
476
- matchLines: 1,
477
- charsPerLine: 1000
478
- },
479
- afterContext: config.contextLines,
480
- beforeContext: config.contextLines,
481
- isSmartCase: this.searchConfig.smartCase,
482
- expandPatterns: true,
483
- notebookSearchConfig: {
484
- includeMarkupInput: config.notebookSearchConfig.includeMarkupInput,
485
- includeMarkupPreview: config.notebookSearchConfig.includeMarkupPreview,
486
- includeCodeInput: config.notebookSearchConfig.includeCodeInput,
487
- includeOutput: config.notebookSearchConfig.includeOutput,
488
- }
489
- };
490
- const folderResources = this.contextService.getWorkspace().folders;
491
- let query;
492
- try {
493
- const queryBuilder = this.instantiationService.createInstance(QueryBuilder);
494
- query = queryBuilder.text(content, ( folderResources.map(folder => folder.uri)), options);
495
- }
496
- catch (err) {
497
- return;
498
- }
499
- this.searchOperation.start(500);
500
- this.ongoingOperations++;
501
- const { configurationModel } = await startInput.resolveModels();
502
- configurationModel.updateConfig(config);
503
- const result = this.searchModel.search(query);
504
- startInput.ongoingSearchOperation = result.asyncResults.finally(() => {
505
- this.ongoingOperations--;
506
- if (this.ongoingOperations === 0) {
507
- this.searchOperation.stop();
508
- }
509
- });
510
- const searchOperation = await startInput.ongoingSearchOperation;
511
- await this.onSearchComplete(searchOperation, config, startInput);
512
- }
513
- async onSearchComplete(searchOperation, startConfig, startInput) {
514
- const input = this.getInput();
515
- if (!input ||
516
- input !== startInput ||
517
- JSON.stringify(startConfig) !== JSON.stringify(this.readConfigFromWidget())) {
518
- return;
519
- }
520
- input.ongoingSearchOperation = undefined;
521
- const sortOrder = this.searchConfig.sortOrder;
522
- if (sortOrder === "modified" ) {
523
- await this.retrieveFileStats(this.searchModel.searchResult);
524
- }
525
- const controller = ReferencesController.get(this.searchResultEditor);
526
- controller?.closeWidget(false);
527
- const labelFormatter = (uri) => this.labelService.getUriLabel(uri, { relative: true });
528
- const results = serializeSearchResultForEditor(this.searchModel.searchResult, startConfig.filesToInclude, startConfig.filesToExclude, startConfig.contextLines, labelFormatter, sortOrder, searchOperation?.limitHit);
529
- const { resultsModel } = await input.resolveModels();
530
- this.updatingModelForSearch = true;
531
- this.modelService.updateModel(resultsModel, results.text);
532
- this.updatingModelForSearch = false;
533
- if (searchOperation && searchOperation.messages) {
534
- for (const message of searchOperation.messages) {
535
- this.addMessage(message);
536
- }
537
- }
538
- this.reLayout();
539
- input.setDirty(!input.hasCapability(4 ));
540
- input.setMatchRanges(results.matchRanges);
541
- }
542
- addMessage(message) {
543
- let messageBox;
544
- if (this.messageBox.firstChild) {
545
- messageBox = this.messageBox.firstChild;
546
- }
547
- else {
548
- messageBox = append(this.messageBox, $('.message'));
549
- }
550
- append(messageBox, renderSearchMessage(message, this.instantiationService, this.notificationService, this.openerService, this.commandService, this.messageDisposables, () => this.triggerSearch()));
551
- }
552
- async retrieveFileStats(searchResult) {
553
- const files = ( searchResult.matches().filter(f => !f.fileStat).map(f => f.resolveFileStat(this.fileService)));
554
- await Promise.all(files);
555
- }
556
- layout(dimension) {
557
- this.dimension = dimension;
558
- this.reLayout();
559
- }
560
- getSelected() {
561
- const selection = this.searchResultEditor.getSelection();
562
- if (selection) {
563
- return this.searchResultEditor.getModel()?.getValueInRange(selection) ?? '';
564
- }
565
- return '';
566
- }
567
- reLayout() {
568
- if (this.dimension) {
569
- this.queryEditorWidget.setWidth(this.dimension.width - 28 );
570
- this.searchResultEditor.layout({ height: this.dimension.height - getTotalHeight(this.queryEditorContainer), width: this.dimension.width });
571
- this.inputPatternExcludes.setWidth(this.dimension.width - 28 );
572
- this.inputPatternIncludes.setWidth(this.dimension.width - 28 );
573
- }
574
- }
575
- getInput() {
576
- return this._input;
577
- }
578
- setSearchConfig(config) {
579
- this.priorConfig = config;
580
- if (config.query !== undefined) {
581
- this.queryEditorWidget.setValue(config.query);
582
- }
583
- if (config.isCaseSensitive !== undefined) {
584
- this.queryEditorWidget.searchInput?.setCaseSensitive(config.isCaseSensitive);
585
- }
586
- if (config.isRegexp !== undefined) {
587
- this.queryEditorWidget.searchInput?.setRegex(config.isRegexp);
588
- }
589
- if (config.matchWholeWord !== undefined) {
590
- this.queryEditorWidget.searchInput?.setWholeWords(config.matchWholeWord);
591
- }
592
- if (config.contextLines !== undefined) {
593
- this.queryEditorWidget.setContextLines(config.contextLines);
594
- }
595
- if (config.filesToExclude !== undefined) {
596
- this.inputPatternExcludes.setValue(config.filesToExclude);
597
- }
598
- if (config.filesToInclude !== undefined) {
599
- this.inputPatternIncludes.setValue(config.filesToInclude);
600
- }
601
- if (config.onlyOpenEditors !== undefined) {
602
- this.inputPatternIncludes.setOnlySearchInOpenEditors(config.onlyOpenEditors);
603
- }
604
- if (config.useExcludeSettingsAndIgnoreFiles !== undefined) {
605
- this.inputPatternExcludes.setUseExcludesAndIgnoreFiles(config.useExcludeSettingsAndIgnoreFiles);
606
- }
607
- if (config.showIncludesExcludes !== undefined) {
608
- this.toggleIncludesExcludes(config.showIncludesExcludes);
609
- }
610
- }
611
- async setInput(newInput, options, context, token) {
612
- await super.setInput(newInput, options, context, token);
613
- if (token.isCancellationRequested) {
614
- return;
615
- }
616
- const { configurationModel, resultsModel } = await newInput.resolveModels();
617
- if (token.isCancellationRequested) {
618
- return;
619
- }
620
- this.searchResultEditor.setModel(resultsModel);
621
- this.pauseSearching = true;
622
- this.toggleRunAgainMessage(!newInput.ongoingSearchOperation && resultsModel.getLineCount() === 1 && resultsModel.getValueLength() === 0 && configurationModel.config.query !== '');
623
- this.setSearchConfig(configurationModel.config);
624
- this._register(configurationModel.onConfigDidUpdate(newConfig => {
625
- if (newConfig !== this.priorConfig) {
626
- this.pauseSearching = true;
627
- this.setSearchConfig(newConfig);
628
- this.pauseSearching = false;
629
- }
630
- }));
631
- this.restoreViewState(context);
632
- if (!options?.preserveFocus) {
633
- this.focus();
634
- }
635
- this.pauseSearching = false;
636
- if (newInput.ongoingSearchOperation) {
637
- const existingConfig = this.readConfigFromWidget();
638
- newInput.ongoingSearchOperation.then(complete => {
639
- this.onSearchComplete(complete, existingConfig, newInput);
640
- });
641
- }
642
- }
643
- toggleIncludesExcludes(_shouldShow) {
644
- const cls = 'expanded';
645
- const shouldShow = _shouldShow ?? !this.includesExcludesContainer.classList.contains(cls);
646
- if (shouldShow) {
647
- this.toggleQueryDetailsButton.setAttribute('aria-expanded', 'true');
648
- this.includesExcludesContainer.classList.add(cls);
649
- }
650
- else {
651
- this.toggleQueryDetailsButton.setAttribute('aria-expanded', 'false');
652
- this.includesExcludesContainer.classList.remove(cls);
653
- }
654
- this.showingIncludesExcludes = this.includesExcludesContainer.classList.contains(cls);
655
- this.reLayout();
656
- }
657
- toEditorViewStateResource(input) {
658
- if (input.typeId === SearchEditorInputTypeId) {
659
- return input.modelUri;
660
- }
661
- return undefined;
662
- }
663
- computeEditorViewState(resource) {
664
- const control = this.getControl();
665
- const editorViewState = control.saveViewState();
666
- if (!editorViewState) {
667
- return undefined;
668
- }
669
- if (( resource.toString()) !== this.getInput()?.modelUri.toString()) {
670
- return undefined;
671
- }
672
- return { ...editorViewState, focused: this.searchResultEditor.hasWidgetFocus() ? 'editor' : 'input' };
673
- }
674
- tracksEditorViewState(input) {
675
- return input.typeId === SearchEditorInputTypeId;
676
- }
677
- restoreViewState(context) {
678
- const viewState = this.loadEditorViewState(this.getInput(), context);
679
- if (viewState) {
680
- this.searchResultEditor.restoreViewState(viewState);
681
- }
682
- }
683
- getAriaLabel() {
684
- return this.getInput()?.getName() ?? ( localizeWithPath(
685
- 'vs/workbench/contrib/searchEditor/browser/searchEditor',
686
- 'searchEditor',
687
- "Search"
688
- ));
689
- }
690
- };
691
- SearchEditor = SearchEditor_1 = ( __decorate([
692
- ( __param(0, ITelemetryService)),
693
- ( __param(1, IThemeService)),
694
- ( __param(2, IStorageService)),
695
- ( __param(3, IModelService)),
696
- ( __param(4, IWorkspaceContextService)),
697
- ( __param(5, ILabelService)),
698
- ( __param(6, IInstantiationService)),
699
- ( __param(7, IContextViewService)),
700
- ( __param(8, ICommandService)),
701
- ( __param(9, IOpenerService)),
702
- ( __param(10, INotificationService)),
703
- ( __param(11, IEditorProgressService)),
704
- ( __param(12, ITextResourceConfigurationService)),
705
- ( __param(13, IEditorGroupsService)),
706
- ( __param(14, IEditorService)),
707
- ( __param(15, IConfigurationService)),
708
- ( __param(16, IFileService)),
709
- ( __param(17, ILogService))
710
- ], SearchEditor));
711
- const searchEditorTextInputBorder = registerColor('searchEditor.textInputBorder', { dark: inputBorder, light: inputBorder, hcDark: inputBorder, hcLight: inputBorder }, ( localizeWithPath(
712
- 'vs/workbench/contrib/searchEditor/browser/searchEditor',
713
- 'textInputBoxBorder',
714
- "Search editor text input box border."
715
- )));
716
- function findNextRange(matchRanges, currentPosition) {
717
- for (const matchRange of matchRanges) {
718
- if (Position.isBefore(currentPosition, matchRange.getStartPosition())) {
719
- return matchRange;
720
- }
721
- }
722
- return matchRanges[0];
723
- }
724
- function findPrevRange(matchRanges, currentPosition) {
725
- for (let i = matchRanges.length - 1; i >= 0; i--) {
726
- const matchRange = matchRanges[i];
727
- if (Position.isBefore(matchRange.getStartPosition(), currentPosition)) {
728
- {
729
- return matchRange;
730
- }
731
- }
732
- }
733
- return matchRanges[matchRanges.length - 1];
734
- }
735
-
736
- export { SearchEditor };