@codingame/monaco-vscode-search-service-override 4.1.0 → 4.1.2
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.
- package/external/rollup-plugin-styles/dist/runtime/inject-css.js +3 -0
- package/external/tslib/tslib.es6.js +11 -0
- package/override/vs/platform/dialogs/common/dialogs.js +10 -0
- package/package.json +2 -2
- package/search.js +4 -4
- package/vscode/src/vs/workbench/contrib/search/browser/anythingQuickAccess.js +796 -0
- package/vscode/src/vs/workbench/contrib/search/browser/media/anythingQuickAccess.css.js +6 -0
- package/vscode/src/vs/workbench/contrib/search/browser/media/searchview.css.js +6 -0
- package/vscode/src/vs/workbench/contrib/search/browser/patternInputWidget.js +234 -0
- package/vscode/src/vs/workbench/contrib/search/browser/quickTextSearch/textSearchQuickAccess.js +341 -0
- package/vscode/src/vs/workbench/contrib/search/browser/replaceContributions.js +9 -0
- package/vscode/src/vs/workbench/contrib/search/browser/replaceService.js +232 -0
- package/vscode/src/vs/workbench/contrib/search/browser/search.contribution.js +647 -0
- package/vscode/src/vs/workbench/contrib/search/browser/searchActionsCopy.js +209 -0
- package/vscode/src/vs/workbench/contrib/search/browser/searchActionsNav.js +511 -0
- package/vscode/src/vs/workbench/contrib/search/browser/searchActionsRemoveReplace.js +374 -0
- package/vscode/src/vs/workbench/contrib/search/browser/searchActionsSymbol.js +43 -0
- package/vscode/src/vs/workbench/contrib/search/browser/searchActionsTextQuickAccess.js +44 -0
- package/vscode/src/vs/workbench/contrib/search/browser/searchActionsTopBar.js +323 -0
- package/vscode/src/vs/workbench/contrib/search/browser/searchFindInput.js +103 -0
- package/vscode/src/vs/workbench/contrib/search/browser/searchIcons.js +106 -0
- package/vscode/src/vs/workbench/contrib/search/browser/searchMessage.js +66 -0
- package/vscode/src/vs/workbench/contrib/search/browser/searchResultsView.js +437 -0
- package/vscode/src/vs/workbench/contrib/search/browser/searchView.js +2177 -0
- package/vscode/src/vs/workbench/contrib/search/browser/searchWidget.js +674 -0
- package/vscode/src/vs/workbench/contrib/search/browser/symbolsQuickAccess.js +234 -0
- package/vscode/src/vs/workbench/contrib/search/common/cacheState.js +87 -0
- package/vscode/src/vs/workbench/contrib/searchEditor/browser/media/searchEditor.css.js +6 -0
- package/vscode/src/vs/workbench/contrib/searchEditor/browser/searchEditor.contribution.js +586 -0
- package/vscode/src/vs/workbench/contrib/searchEditor/browser/searchEditor.js +760 -0
- package/vscode/src/vs/workbench/contrib/searchEditor/browser/searchEditorActions.js +189 -0
- package/vscode/src/vs/workbench/contrib/searchEditor/browser/searchEditorInput.js +320 -0
- package/vscode/src/vs/workbench/contrib/searchEditor/browser/searchEditorModel.js +138 -0
- package/vscode/src/vs/workbench/contrib/searchEditor/browser/searchEditorSerialization.js +293 -0
- package/vscode/src/vs/workbench/services/search/common/searchService.js +416 -0
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
+
import { localizeWithPath } from 'vscode/vscode/vs/nls';
|
|
3
|
+
import { Schemas } from 'vscode/vscode/vs/base/common/network';
|
|
4
|
+
import { Disposable } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
5
|
+
import { IReplaceService } from 'vscode/vscode/vs/workbench/contrib/search/browser/replace';
|
|
6
|
+
import { IEditorService } from 'vscode/vscode/vs/workbench/services/editor/common/editorService';
|
|
7
|
+
import { IModelService } from 'vscode/vscode/vs/editor/common/services/model';
|
|
8
|
+
import { ILanguageService } from 'vscode/vscode/vs/editor/common/languages/language';
|
|
9
|
+
import { Match, MatchInNotebook, FileMatch, ISearchViewModelWorkbenchService } from 'vscode/vscode/vs/workbench/contrib/search/browser/searchModel';
|
|
10
|
+
import { ITextModelService } from 'vscode/vscode/vs/editor/common/services/resolverService';
|
|
11
|
+
import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
12
|
+
import { createTextBufferFactoryFromSnapshot } from 'vscode/vscode/vs/editor/common/model/textModel';
|
|
13
|
+
import { ITextFileService } from 'vscode/vscode/vs/workbench/services/textfile/common/textfiles';
|
|
14
|
+
import { ResourceTextEdit, IBulkEditService } from 'vscode/vscode/vs/editor/browser/services/bulkEditService';
|
|
15
|
+
import { Range } from 'vscode/vscode/vs/editor/common/core/range';
|
|
16
|
+
import { EditOperation } from 'vscode/vscode/vs/editor/common/core/editOperation';
|
|
17
|
+
import { ILabelService } from 'vscode/vscode/vs/platform/label/common/label';
|
|
18
|
+
import { dirname } from 'vscode/vscode/vs/base/common/resources';
|
|
19
|
+
import { Promises } from 'vscode/vscode/vs/base/common/async';
|
|
20
|
+
import { SaveSourceRegistry } from 'vscode/vscode/vs/workbench/common/editor';
|
|
21
|
+
import { CellUri } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookCommon';
|
|
22
|
+
import { INotebookEditorModelResolverService } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookEditorModelResolverService';
|
|
23
|
+
|
|
24
|
+
var ReplaceService_1;
|
|
25
|
+
const REPLACE_PREVIEW = 'replacePreview';
|
|
26
|
+
const toReplaceResource = (fileResource) => {
|
|
27
|
+
return fileResource.with({ scheme: Schemas.internal, fragment: REPLACE_PREVIEW, query: JSON.stringify({ scheme: fileResource.scheme }) });
|
|
28
|
+
};
|
|
29
|
+
const toFileResource = (replaceResource) => {
|
|
30
|
+
return replaceResource.with({ scheme: JSON.parse(replaceResource.query)['scheme'], fragment: '', query: '' });
|
|
31
|
+
};
|
|
32
|
+
let ReplacePreviewContentProvider = class ReplacePreviewContentProvider {
|
|
33
|
+
static { this.ID = 'workbench.contrib.replacePreviewContentProvider'; }
|
|
34
|
+
constructor(instantiationService, textModelResolverService) {
|
|
35
|
+
this.instantiationService = instantiationService;
|
|
36
|
+
this.textModelResolverService = textModelResolverService;
|
|
37
|
+
this.textModelResolverService.registerTextModelContentProvider(Schemas.internal, this);
|
|
38
|
+
}
|
|
39
|
+
provideTextContent(uri) {
|
|
40
|
+
if (uri.fragment === REPLACE_PREVIEW) {
|
|
41
|
+
return this.instantiationService.createInstance(ReplacePreviewModel).resolve(uri);
|
|
42
|
+
}
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
ReplacePreviewContentProvider = ( __decorate([
|
|
47
|
+
( __param(0, IInstantiationService)),
|
|
48
|
+
( __param(1, ITextModelService))
|
|
49
|
+
], ReplacePreviewContentProvider));
|
|
50
|
+
let ReplacePreviewModel = class ReplacePreviewModel extends Disposable {
|
|
51
|
+
constructor(modelService, languageService, textModelResolverService, replaceService, searchWorkbenchService) {
|
|
52
|
+
super();
|
|
53
|
+
this.modelService = modelService;
|
|
54
|
+
this.languageService = languageService;
|
|
55
|
+
this.textModelResolverService = textModelResolverService;
|
|
56
|
+
this.replaceService = replaceService;
|
|
57
|
+
this.searchWorkbenchService = searchWorkbenchService;
|
|
58
|
+
}
|
|
59
|
+
async resolve(replacePreviewUri) {
|
|
60
|
+
const fileResource = toFileResource(replacePreviewUri);
|
|
61
|
+
const fileMatch = this.searchWorkbenchService.searchModel.searchResult.matches().filter(match => ( match.resource.toString()) === ( fileResource.toString()))[0];
|
|
62
|
+
const ref = this._register(await this.textModelResolverService.createModelReference(fileResource));
|
|
63
|
+
const sourceModel = ref.object.textEditorModel;
|
|
64
|
+
const sourceModelLanguageId = sourceModel.getLanguageId();
|
|
65
|
+
const replacePreviewModel = this.modelService.createModel(createTextBufferFactoryFromSnapshot(sourceModel.createSnapshot()), this.languageService.createById(sourceModelLanguageId), replacePreviewUri);
|
|
66
|
+
this._register(fileMatch.onChange(({ forceUpdateModel }) => this.update(sourceModel, replacePreviewModel, fileMatch, forceUpdateModel)));
|
|
67
|
+
this._register(this.searchWorkbenchService.searchModel.onReplaceTermChanged(() => this.update(sourceModel, replacePreviewModel, fileMatch)));
|
|
68
|
+
this._register(fileMatch.onDispose(() => replacePreviewModel.dispose()));
|
|
69
|
+
this._register(replacePreviewModel.onWillDispose(() => this.dispose()));
|
|
70
|
+
this._register(sourceModel.onWillDispose(() => this.dispose()));
|
|
71
|
+
return replacePreviewModel;
|
|
72
|
+
}
|
|
73
|
+
update(sourceModel, replacePreviewModel, fileMatch, override = false) {
|
|
74
|
+
if (!sourceModel.isDisposed() && !replacePreviewModel.isDisposed()) {
|
|
75
|
+
this.replaceService.updateReplacePreview(fileMatch, override);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
ReplacePreviewModel = ( __decorate([
|
|
80
|
+
( __param(0, IModelService)),
|
|
81
|
+
( __param(1, ILanguageService)),
|
|
82
|
+
( __param(2, ITextModelService)),
|
|
83
|
+
( __param(3, IReplaceService)),
|
|
84
|
+
( __param(4, ISearchViewModelWorkbenchService))
|
|
85
|
+
], ReplacePreviewModel));
|
|
86
|
+
let ReplaceService = class ReplaceService {
|
|
87
|
+
static { ReplaceService_1 = this; }
|
|
88
|
+
static { this.REPLACE_SAVE_SOURCE = SaveSourceRegistry.registerSource('searchReplace.source', ( localizeWithPath(
|
|
89
|
+
'vs/workbench/contrib/search/browser/replaceService',
|
|
90
|
+
'searchReplace.source',
|
|
91
|
+
"Search and Replace"
|
|
92
|
+
))); }
|
|
93
|
+
constructor(textFileService, editorService, textModelResolverService, bulkEditorService, labelService, notebookEditorModelResolverService) {
|
|
94
|
+
this.textFileService = textFileService;
|
|
95
|
+
this.editorService = editorService;
|
|
96
|
+
this.textModelResolverService = textModelResolverService;
|
|
97
|
+
this.bulkEditorService = bulkEditorService;
|
|
98
|
+
this.labelService = labelService;
|
|
99
|
+
this.notebookEditorModelResolverService = notebookEditorModelResolverService;
|
|
100
|
+
}
|
|
101
|
+
async replace(arg, progress = undefined, resource = null) {
|
|
102
|
+
const edits = this.createEdits(arg, resource);
|
|
103
|
+
await this.bulkEditorService.apply(edits, { progress });
|
|
104
|
+
const rawTextPromises = ( edits.map(async (e) => {
|
|
105
|
+
if (e.resource.scheme === Schemas.vscodeNotebookCell) {
|
|
106
|
+
const notebookResource = CellUri.parse(e.resource)?.notebook;
|
|
107
|
+
if (notebookResource) {
|
|
108
|
+
let ref;
|
|
109
|
+
try {
|
|
110
|
+
ref = await this.notebookEditorModelResolverService.resolve(notebookResource);
|
|
111
|
+
await ref.object.save({ source: ReplaceService_1.REPLACE_SAVE_SOURCE });
|
|
112
|
+
}
|
|
113
|
+
finally {
|
|
114
|
+
ref?.dispose();
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
return this.textFileService.files.get(e.resource)?.save({ source: ReplaceService_1.REPLACE_SAVE_SOURCE });
|
|
121
|
+
}
|
|
122
|
+
}));
|
|
123
|
+
return Promises.settled(rawTextPromises);
|
|
124
|
+
}
|
|
125
|
+
async openReplacePreview(element, preserveFocus, sideBySide, pinned) {
|
|
126
|
+
const fileMatch = element instanceof Match ? element.parent() : element;
|
|
127
|
+
const editor = await this.editorService.openEditor({
|
|
128
|
+
original: { resource: fileMatch.resource },
|
|
129
|
+
modified: { resource: toReplaceResource(fileMatch.resource) },
|
|
130
|
+
label: ( localizeWithPath(
|
|
131
|
+
'vs/workbench/contrib/search/browser/replaceService',
|
|
132
|
+
'fileReplaceChanges',
|
|
133
|
+
"{0} ↔ {1} (Replace Preview)",
|
|
134
|
+
fileMatch.name(),
|
|
135
|
+
fileMatch.name()
|
|
136
|
+
)),
|
|
137
|
+
description: this.labelService.getUriLabel(dirname(fileMatch.resource), { relative: true }),
|
|
138
|
+
options: {
|
|
139
|
+
preserveFocus,
|
|
140
|
+
pinned,
|
|
141
|
+
revealIfVisible: true
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
const input = editor?.input;
|
|
145
|
+
const disposable = fileMatch.onDispose(() => {
|
|
146
|
+
input?.dispose();
|
|
147
|
+
disposable.dispose();
|
|
148
|
+
});
|
|
149
|
+
await this.updateReplacePreview(fileMatch);
|
|
150
|
+
if (editor) {
|
|
151
|
+
const editorControl = editor.getControl();
|
|
152
|
+
if (element instanceof Match && editorControl) {
|
|
153
|
+
editorControl.revealLineInCenter(element.range().startLineNumber, 1 );
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
async updateReplacePreview(fileMatch, override = false) {
|
|
158
|
+
const replacePreviewUri = toReplaceResource(fileMatch.resource);
|
|
159
|
+
const [sourceModelRef, replaceModelRef] = await Promise.all([this.textModelResolverService.createModelReference(fileMatch.resource), this.textModelResolverService.createModelReference(replacePreviewUri)]);
|
|
160
|
+
const sourceModel = sourceModelRef.object.textEditorModel;
|
|
161
|
+
const replaceModel = replaceModelRef.object.textEditorModel;
|
|
162
|
+
try {
|
|
163
|
+
if (sourceModel && replaceModel) {
|
|
164
|
+
if (override) {
|
|
165
|
+
replaceModel.setValue(sourceModel.getValue());
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
replaceModel.undo();
|
|
169
|
+
}
|
|
170
|
+
this.applyEditsToPreview(fileMatch, replaceModel);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
finally {
|
|
174
|
+
sourceModelRef.dispose();
|
|
175
|
+
replaceModelRef.dispose();
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
applyEditsToPreview(fileMatch, replaceModel) {
|
|
179
|
+
const resourceEdits = this.createEdits(fileMatch, replaceModel.uri);
|
|
180
|
+
const modelEdits = [];
|
|
181
|
+
for (const resourceEdit of resourceEdits) {
|
|
182
|
+
modelEdits.push(EditOperation.replaceMove(Range.lift(resourceEdit.textEdit.range), resourceEdit.textEdit.text));
|
|
183
|
+
}
|
|
184
|
+
replaceModel.pushEditOperations([], modelEdits.sort((a, b) => Range.compareRangesUsingStarts(a.range, b.range)), () => []);
|
|
185
|
+
}
|
|
186
|
+
createEdits(arg, resource = null) {
|
|
187
|
+
const edits = [];
|
|
188
|
+
if (arg instanceof Match) {
|
|
189
|
+
if (arg instanceof MatchInNotebook) {
|
|
190
|
+
if (!arg.isReadonly()) {
|
|
191
|
+
const match = arg;
|
|
192
|
+
edits.push(this.createEdit(match, match.replaceString, match.cell?.uri));
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
const match = arg;
|
|
197
|
+
edits.push(this.createEdit(match, match.replaceString, resource));
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
if (arg instanceof FileMatch) {
|
|
201
|
+
arg = [arg];
|
|
202
|
+
}
|
|
203
|
+
if (arg instanceof Array) {
|
|
204
|
+
arg.forEach(element => {
|
|
205
|
+
const fileMatch = element;
|
|
206
|
+
if (fileMatch.count() > 0) {
|
|
207
|
+
edits.push(...fileMatch.matches().flatMap(match => this.createEdits(match, resource)));
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
return edits;
|
|
212
|
+
}
|
|
213
|
+
createEdit(match, text, resource = null) {
|
|
214
|
+
const fileMatch = match.parent();
|
|
215
|
+
return ( new ResourceTextEdit(
|
|
216
|
+
resource ?? fileMatch.resource,
|
|
217
|
+
{ range: match.range(), text },
|
|
218
|
+
undefined,
|
|
219
|
+
undefined
|
|
220
|
+
));
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
ReplaceService = ReplaceService_1 = ( __decorate([
|
|
224
|
+
( __param(0, ITextFileService)),
|
|
225
|
+
( __param(1, IEditorService)),
|
|
226
|
+
( __param(2, ITextModelService)),
|
|
227
|
+
( __param(3, IBulkEditService)),
|
|
228
|
+
( __param(4, ILabelService)),
|
|
229
|
+
( __param(5, INotebookEditorModelResolverService))
|
|
230
|
+
], ReplaceService));
|
|
231
|
+
|
|
232
|
+
export { ReplacePreviewContentProvider, ReplaceService };
|