@codingame/monaco-vscode-search-service-override 25.1.2 → 26.0.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.
- package/package.json +2 -2
- package/vscode/src/vs/workbench/contrib/search/browser/quickTextSearch/textSearchQuickAccess.js +70 -52
- package/vscode/src/vs/workbench/contrib/search/browser/replaceContributions.js +5 -1
- package/vscode/src/vs/workbench/contrib/search/browser/replaceService.js +96 -59
- package/vscode/src/vs/workbench/contrib/search/browser/search.contribution.js +256 -273
- package/vscode/src/vs/workbench/contrib/search/browser/searchActionsCopy.js +66 -50
- package/vscode/src/vs/workbench/contrib/search/browser/searchActionsNav.js +64 -62
- package/vscode/src/vs/workbench/contrib/search/browser/searchActionsRemoveReplace.js +102 -130
- package/vscode/src/vs/workbench/contrib/search/browser/searchActionsSymbol.js +12 -6
- package/vscode/src/vs/workbench/contrib/search/browser/searchActionsTextQuickAccess.js +6 -4
- package/vscode/src/vs/workbench/contrib/search/browser/searchTreeModel/searchModel.js +76 -48
- package/vscode/src/vs/workbench/contrib/search/browser/searchTreeModel/searchResult.js +28 -34
- package/vscode/src/vs/workbench/contrib/searchEditor/browser/searchEditor.contribution.js +206 -117
- package/vscode/src/vs/workbench/contrib/searchEditor/browser/searchEditor.js +287 -167
- package/vscode/src/vs/workbench/services/search/browser/searchService.js +48 -33
- package/vscode/src/vs/workbench/services/search/common/getFileResults.js +28 -18
- package/vscode/src/vs/workbench/services/search/common/replace.js +53 -43
- package/vscode/src/vs/workbench/services/search/common/searchService.js +95 -90
- package/vscode/src/vs/workbench/services/search/worker/localFileSearch.js +74 -57
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codingame/monaco-vscode-search-service-override",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "26.0.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "VSCode public API plugged on the monaco editor - search service-override",
|
|
6
6
|
"keywords": [],
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
},
|
|
16
16
|
"type": "module",
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@codingame/monaco-vscode-api": "
|
|
18
|
+
"@codingame/monaco-vscode-api": "26.0.0"
|
|
19
19
|
},
|
|
20
20
|
"main": "index.js",
|
|
21
21
|
"module": "index.js",
|
package/vscode/src/vs/workbench/contrib/search/browser/quickTextSearch/textSearchQuickAccess.js
CHANGED
|
@@ -30,9 +30,9 @@ import { SearchModelImpl } from '../searchTreeModel/searchModel.js';
|
|
|
30
30
|
import { SearchModelLocation } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/search/browser/searchTreeModel/searchTreeCommon';
|
|
31
31
|
import { searchComparer } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/search/browser/searchCompare';
|
|
32
32
|
|
|
33
|
-
const TEXT_SEARCH_QUICK_ACCESS_PREFIX =
|
|
33
|
+
const TEXT_SEARCH_QUICK_ACCESS_PREFIX = "%";
|
|
34
34
|
const DEFAULT_TEXT_QUERY_BUILDER_OPTIONS = {
|
|
35
|
-
_reason:
|
|
35
|
+
_reason: "quickAccessSearch",
|
|
36
36
|
disregardIgnoreFiles: false,
|
|
37
37
|
disregardExcludeSettings: false,
|
|
38
38
|
onlyOpenEditors: false,
|
|
@@ -48,7 +48,7 @@ let TextSearchQuickAccess = class TextSearchQuickAccess extends PickerQuickAcces
|
|
|
48
48
|
...{
|
|
49
49
|
extraFileResources: this._instantiationService.invokeFunction(getOutOfWorkspaceEditorResources),
|
|
50
50
|
maxResults: this.configuration.maxResults ?? undefined,
|
|
51
|
-
isSmartCase: this.configuration.smartCase
|
|
51
|
+
isSmartCase: this.configuration.smartCase
|
|
52
52
|
},
|
|
53
53
|
previewOptions: {
|
|
54
54
|
matchLines: 1,
|
|
@@ -56,8 +56,18 @@ let TextSearchQuickAccess = class TextSearchQuickAccess extends PickerQuickAcces
|
|
|
56
56
|
}
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
|
-
constructor(
|
|
60
|
-
|
|
59
|
+
constructor(
|
|
60
|
+
_instantiationService,
|
|
61
|
+
_contextService,
|
|
62
|
+
_editorService,
|
|
63
|
+
_labelService,
|
|
64
|
+
_viewsService,
|
|
65
|
+
_configurationService
|
|
66
|
+
) {
|
|
67
|
+
super(TEXT_SEARCH_QUICK_ACCESS_PREFIX, {
|
|
68
|
+
canAcceptInBackground: true,
|
|
69
|
+
shouldSkipTrimPickFilter: true
|
|
70
|
+
});
|
|
61
71
|
this._instantiationService = _instantiationService;
|
|
62
72
|
this._contextService = _contextService;
|
|
63
73
|
this._editorService = _editorService;
|
|
@@ -84,10 +94,10 @@ let TextSearchQuickAccess = class TextSearchQuickAccess extends PickerQuickAcces
|
|
|
84
94
|
picker.valueSelection = [TEXT_SEARCH_QUICK_ACCESS_PREFIX.length, picker.value.length];
|
|
85
95
|
}
|
|
86
96
|
picker.buttons = [{
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
97
|
+
location: QuickInputButtonLocation.Inline,
|
|
98
|
+
iconClass: ThemeIcon.asClassName(Codicon.goToSearch),
|
|
99
|
+
tooltip: ( localize(10990, "Open in Search View"))
|
|
100
|
+
}];
|
|
91
101
|
this.editorViewState.reset();
|
|
92
102
|
disposables.add(picker.onDidTriggerButton(async () => {
|
|
93
103
|
await this.moveToSearchViewlet(undefined);
|
|
@@ -101,22 +111,39 @@ let TextSearchQuickAccess = class TextSearchQuickAccess extends PickerQuickAcces
|
|
|
101
111
|
this.editorSequencer.queue(async () => {
|
|
102
112
|
await this.editorViewState.openTransientEditor({
|
|
103
113
|
resource: itemMatch.parent().resource,
|
|
104
|
-
options: {
|
|
114
|
+
options: {
|
|
115
|
+
preserveFocus: true,
|
|
116
|
+
revealIfOpened: true,
|
|
117
|
+
ignoreError: true,
|
|
118
|
+
selection: itemMatch.range()
|
|
119
|
+
}
|
|
105
120
|
});
|
|
106
121
|
});
|
|
107
122
|
}
|
|
108
123
|
};
|
|
109
|
-
disposables.add(
|
|
110
|
-
|
|
124
|
+
disposables.add(
|
|
125
|
+
Event.debounce(picker.onDidChangeActive, (last, event) => event, DEBOUNCE_DELAY, true)(onDidChangeActive)
|
|
126
|
+
);
|
|
127
|
+
disposables.add(Event.once(picker.onWillHide)((
|
|
128
|
+
{
|
|
129
|
+
reason
|
|
130
|
+
}
|
|
131
|
+
) => {
|
|
111
132
|
if (reason === QuickInputHideReason.Gesture) {
|
|
112
133
|
this.editorViewState.restore();
|
|
113
134
|
}
|
|
114
135
|
}));
|
|
115
|
-
disposables.add(Event.once(picker.onDidHide)((
|
|
136
|
+
disposables.add(Event.once(picker.onDidHide)((
|
|
137
|
+
{
|
|
138
|
+
reason
|
|
139
|
+
}
|
|
140
|
+
) => {
|
|
116
141
|
this.searchModel.searchResult.toggleHighlights(false);
|
|
117
142
|
}));
|
|
118
143
|
disposables.add(super.provide(picker, token, runOptions));
|
|
119
|
-
disposables.add(
|
|
144
|
+
disposables.add(
|
|
145
|
+
picker.onDidAccept(() => this.searchModel.searchResult.toggleHighlights(false))
|
|
146
|
+
);
|
|
120
147
|
return disposables;
|
|
121
148
|
}
|
|
122
149
|
get configuration() {
|
|
@@ -127,7 +154,7 @@ let TextSearchQuickAccess = class TextSearchQuickAccess extends PickerQuickAcces
|
|
|
127
154
|
preserveInput: searchConfig.quickAccess.preserveInput,
|
|
128
155
|
maxResults: searchConfig.maxResults,
|
|
129
156
|
smartCase: searchConfig.smartCase,
|
|
130
|
-
sortOrder: searchConfig.sortOrder
|
|
157
|
+
sortOrder: searchConfig.sortOrder
|
|
131
158
|
};
|
|
132
159
|
}
|
|
133
160
|
get defaultFilterValue() {
|
|
@@ -137,12 +164,12 @@ let TextSearchQuickAccess = class TextSearchQuickAccess extends PickerQuickAcces
|
|
|
137
164
|
return undefined;
|
|
138
165
|
}
|
|
139
166
|
doSearch(contentPattern, token) {
|
|
140
|
-
if (contentPattern ===
|
|
167
|
+
if (contentPattern === "") {
|
|
141
168
|
return undefined;
|
|
142
169
|
}
|
|
143
170
|
const folderResources = this._contextService.getWorkspace().folders;
|
|
144
171
|
const content = {
|
|
145
|
-
pattern: contentPattern
|
|
172
|
+
pattern: contentPattern
|
|
146
173
|
};
|
|
147
174
|
this.searchModel.searchResult.toggleHighlights(false);
|
|
148
175
|
const charsPerLine = content.isRegExp ? 10000 : 1000;
|
|
@@ -170,8 +197,7 @@ let TextSearchQuickAccess = class TextSearchQuickAccess extends PickerQuickAcces
|
|
|
170
197
|
viewer.setFocus([currentElem], getSelectionKeyboardEvent());
|
|
171
198
|
viewer.setSelection([currentElem], getSelectionKeyboardEvent());
|
|
172
199
|
viewer.reveal(currentElem);
|
|
173
|
-
}
|
|
174
|
-
else {
|
|
200
|
+
} else {
|
|
175
201
|
viewlet.searchAndReplaceWidget.focus();
|
|
176
202
|
}
|
|
177
203
|
}
|
|
@@ -180,8 +206,7 @@ let TextSearchQuickAccess = class TextSearchQuickAccess extends PickerQuickAcces
|
|
|
180
206
|
if (firstFile) {
|
|
181
207
|
if (firstFile === a.resource) {
|
|
182
208
|
return -1;
|
|
183
|
-
}
|
|
184
|
-
else if (firstFile === b.resource) {
|
|
209
|
+
} else if (firstFile === b.resource) {
|
|
185
210
|
return 1;
|
|
186
211
|
}
|
|
187
212
|
}
|
|
@@ -192,10 +217,10 @@ let TextSearchQuickAccess = class TextSearchQuickAccess extends PickerQuickAcces
|
|
|
192
217
|
for (let fileIndex = 0; fileIndex < matches.length; fileIndex++) {
|
|
193
218
|
if (fileIndex === limit) {
|
|
194
219
|
picks.push({
|
|
195
|
-
type:
|
|
220
|
+
type: "separator"
|
|
196
221
|
});
|
|
197
222
|
picks.push({
|
|
198
|
-
label: ( localize(
|
|
223
|
+
label: ( localize(10991, "See More Files")),
|
|
199
224
|
iconClass: ThemeIcon.asClassName(searchDetailsIcon),
|
|
200
225
|
accept: async () => {
|
|
201
226
|
await this.moveToSearchViewlet(matches[limit]);
|
|
@@ -205,26 +230,28 @@ let TextSearchQuickAccess = class TextSearchQuickAccess extends PickerQuickAcces
|
|
|
205
230
|
}
|
|
206
231
|
const iFileInstanceMatch = files[fileIndex];
|
|
207
232
|
const label = basenameOrAuthority(iFileInstanceMatch.resource);
|
|
208
|
-
const description = this._labelService.getUriLabel(dirname(iFileInstanceMatch.resource), {
|
|
233
|
+
const description = this._labelService.getUriLabel(dirname(iFileInstanceMatch.resource), {
|
|
234
|
+
relative: true
|
|
235
|
+
});
|
|
209
236
|
picks.push({
|
|
210
237
|
label,
|
|
211
|
-
type:
|
|
238
|
+
type: "separator",
|
|
212
239
|
description,
|
|
213
240
|
buttons: [{
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
241
|
+
iconClass: ThemeIcon.asClassName(searchOpenInFileIcon),
|
|
242
|
+
tooltip: ( localize(10992, "Open File"))
|
|
243
|
+
}],
|
|
217
244
|
trigger: async () => {
|
|
218
245
|
await this.handleAccept(iFileInstanceMatch, {});
|
|
219
246
|
return TriggerAction.CLOSE_PICKER;
|
|
220
|
-
}
|
|
247
|
+
}
|
|
221
248
|
});
|
|
222
249
|
const results = iFileInstanceMatch.matches() ?? [];
|
|
223
250
|
for (let matchIndex = 0; matchIndex < results.length; matchIndex++) {
|
|
224
251
|
const element = results[matchIndex];
|
|
225
252
|
if (matchIndex === MAX_RESULTS_PER_FILE) {
|
|
226
253
|
picks.push({
|
|
227
|
-
label: ( localize(
|
|
254
|
+
label: ( localize(10993, "More")),
|
|
228
255
|
iconClass: ThemeIcon.asClassName(searchDetailsIcon),
|
|
229
256
|
accept: async () => {
|
|
230
257
|
await this.moveToSearchViewlet(element);
|
|
@@ -235,18 +262,18 @@ let TextSearchQuickAccess = class TextSearchQuickAccess extends PickerQuickAcces
|
|
|
235
262
|
const preview = element.preview();
|
|
236
263
|
const previewText = (preview.before + preview.inside + preview.after).trim().substring(0, 999);
|
|
237
264
|
const match = [{
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
265
|
+
start: preview.before.length,
|
|
266
|
+
end: preview.before.length + preview.inside.length
|
|
267
|
+
}];
|
|
241
268
|
picks.push({
|
|
242
269
|
label: `${previewText}`,
|
|
243
270
|
highlights: {
|
|
244
271
|
label: match
|
|
245
272
|
},
|
|
246
273
|
buttons: [{
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
274
|
+
iconClass: ThemeIcon.asClassName(searchActivityBarIcon),
|
|
275
|
+
tooltip: ( localize(10994, "Open in Search View"))
|
|
276
|
+
}],
|
|
250
277
|
ariaLabel: `Match at location ${element.range().startLineNumber}:${element.range().startColumn} - ${previewText}`,
|
|
251
278
|
accept: async (keyMods, event) => {
|
|
252
279
|
await this.handleAccept(iFileInstanceMatch, {
|
|
@@ -280,11 +307,11 @@ let TextSearchQuickAccess = class TextSearchQuickAccess extends PickerQuickAcces
|
|
|
280
307
|
}
|
|
281
308
|
_getPicks(contentPattern, disposables, token) {
|
|
282
309
|
const searchModelAtTimeOfSearch = this.searchModel;
|
|
283
|
-
if (contentPattern ===
|
|
310
|
+
if (contentPattern === "") {
|
|
284
311
|
this.searchModel.searchResult.clear();
|
|
285
312
|
return [{
|
|
286
|
-
|
|
287
|
-
|
|
313
|
+
label: ( localize(10995, "Enter a term to search for across your files."))
|
|
314
|
+
}];
|
|
288
315
|
}
|
|
289
316
|
const conditionalTokenCts = disposables.add(( new CancellationTokenSource()));
|
|
290
317
|
disposables.add(token.onCancellationRequested(() => {
|
|
@@ -306,11 +333,9 @@ let TextSearchQuickAccess = class TextSearchQuickAccess extends PickerQuickAcces
|
|
|
306
333
|
}
|
|
307
334
|
return {
|
|
308
335
|
picks: syncResult,
|
|
309
|
-
additionalPicks: allMatches.asyncResults
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
}] : this._getPicksFromMatches(asyncResults, MAX_FILES_SHOWN - matches.length))
|
|
313
|
-
.then(picks => {
|
|
336
|
+
additionalPicks: allMatches.asyncResults.then(asyncResults => (asyncResults.length + syncResult.length === 0) ? [{
|
|
337
|
+
label: ( localize(10996, "No matching results"))
|
|
338
|
+
}] : this._getPicksFromMatches(asyncResults, MAX_FILES_SHOWN - matches.length)).then(picks => {
|
|
314
339
|
if (picks.length > 0) {
|
|
315
340
|
this.searchModel.searchResult.toggleHighlights(true);
|
|
316
341
|
}
|
|
@@ -319,13 +344,6 @@ let TextSearchQuickAccess = class TextSearchQuickAccess extends PickerQuickAcces
|
|
|
319
344
|
};
|
|
320
345
|
}
|
|
321
346
|
};
|
|
322
|
-
TextSearchQuickAccess = ( __decorate([
|
|
323
|
-
( __param(0, IInstantiationService)),
|
|
324
|
-
( __param(1, IWorkspaceContextService)),
|
|
325
|
-
( __param(2, IEditorService)),
|
|
326
|
-
( __param(3, ILabelService)),
|
|
327
|
-
( __param(4, IViewsService)),
|
|
328
|
-
( __param(5, IConfigurationService))
|
|
329
|
-
], TextSearchQuickAccess));
|
|
347
|
+
TextSearchQuickAccess = ( __decorate([( __param(0, IInstantiationService)), ( __param(1, IWorkspaceContextService)), ( __param(2, IEditorService)), ( __param(3, ILabelService)), ( __param(4, IViewsService)), ( __param(5, IConfigurationService))], TextSearchQuickAccess));
|
|
330
348
|
|
|
331
349
|
export { TEXT_SEARCH_QUICK_ACCESS_PREFIX, TextSearchQuickAccess };
|
|
@@ -5,7 +5,11 @@ import { ReplacePreviewContentProvider } from './replaceService.js';
|
|
|
5
5
|
import { registerWorkbenchContribution2, WorkbenchPhase } from '@codingame/monaco-vscode-api/vscode/vs/workbench/common/contributions';
|
|
6
6
|
|
|
7
7
|
function registerContributions() {
|
|
8
|
-
registerWorkbenchContribution2(
|
|
8
|
+
registerWorkbenchContribution2(
|
|
9
|
+
ReplacePreviewContentProvider.ID,
|
|
10
|
+
ReplacePreviewContentProvider,
|
|
11
|
+
WorkbenchPhase.BlockStartup
|
|
12
|
+
);
|
|
9
13
|
}
|
|
10
14
|
|
|
11
15
|
export { registerContributions };
|
|
@@ -27,15 +27,27 @@ import { isSearchTreeMatch, isSearchTreeFileMatch } from '@codingame/monaco-vsco
|
|
|
27
27
|
import { isIMatchInNotebook } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/search/browser/notebookSearch/notebookSearchModelBase';
|
|
28
28
|
|
|
29
29
|
var ReplaceService_1;
|
|
30
|
-
const REPLACE_PREVIEW =
|
|
31
|
-
const toReplaceResource =
|
|
32
|
-
return fileResource.with({
|
|
30
|
+
const REPLACE_PREVIEW = "replacePreview";
|
|
31
|
+
const toReplaceResource = fileResource => {
|
|
32
|
+
return fileResource.with({
|
|
33
|
+
scheme: Schemas.internal,
|
|
34
|
+
fragment: REPLACE_PREVIEW,
|
|
35
|
+
query: JSON.stringify({
|
|
36
|
+
scheme: fileResource.scheme
|
|
37
|
+
})
|
|
38
|
+
});
|
|
33
39
|
};
|
|
34
|
-
const toFileResource =
|
|
35
|
-
return replaceResource.with({
|
|
40
|
+
const toFileResource = replaceResource => {
|
|
41
|
+
return replaceResource.with({
|
|
42
|
+
scheme: JSON.parse(replaceResource.query)["scheme"],
|
|
43
|
+
fragment: "",
|
|
44
|
+
query: ""
|
|
45
|
+
});
|
|
36
46
|
};
|
|
37
47
|
let ReplacePreviewContentProvider = class ReplacePreviewContentProvider {
|
|
38
|
-
static {
|
|
48
|
+
static {
|
|
49
|
+
this.ID = "workbench.contrib.replacePreviewContentProvider";
|
|
50
|
+
}
|
|
39
51
|
constructor(instantiationService, textModelResolverService) {
|
|
40
52
|
this.instantiationService = instantiationService;
|
|
41
53
|
this.textModelResolverService = textModelResolverService;
|
|
@@ -48,12 +60,15 @@ let ReplacePreviewContentProvider = class ReplacePreviewContentProvider {
|
|
|
48
60
|
return null;
|
|
49
61
|
}
|
|
50
62
|
};
|
|
51
|
-
ReplacePreviewContentProvider = ( __decorate([
|
|
52
|
-
( __param(0, IInstantiationService)),
|
|
53
|
-
( __param(1, ITextModelService))
|
|
54
|
-
], ReplacePreviewContentProvider));
|
|
63
|
+
ReplacePreviewContentProvider = ( __decorate([( __param(0, IInstantiationService)), ( __param(1, ITextModelService))], ReplacePreviewContentProvider));
|
|
55
64
|
let ReplacePreviewModel = class ReplacePreviewModel extends Disposable {
|
|
56
|
-
constructor(
|
|
65
|
+
constructor(
|
|
66
|
+
modelService,
|
|
67
|
+
languageService,
|
|
68
|
+
textModelResolverService,
|
|
69
|
+
replaceService,
|
|
70
|
+
searchWorkbenchService
|
|
71
|
+
) {
|
|
57
72
|
super();
|
|
58
73
|
this.modelService = modelService;
|
|
59
74
|
this.languageService = languageService;
|
|
@@ -67,9 +82,19 @@ let ReplacePreviewModel = class ReplacePreviewModel extends Disposable {
|
|
|
67
82
|
const ref = this._register(await this.textModelResolverService.createModelReference(fileResource));
|
|
68
83
|
const sourceModel = ref.object.textEditorModel;
|
|
69
84
|
const sourceModelLanguageId = sourceModel.getLanguageId();
|
|
70
|
-
const replacePreviewModel = this.modelService.createModel(
|
|
71
|
-
|
|
72
|
-
|
|
85
|
+
const replacePreviewModel = this.modelService.createModel(
|
|
86
|
+
createTextBufferFactoryFromSnapshot(sourceModel.createSnapshot()),
|
|
87
|
+
this.languageService.createById(sourceModelLanguageId),
|
|
88
|
+
replacePreviewUri
|
|
89
|
+
);
|
|
90
|
+
this._register(fileMatch.onChange((
|
|
91
|
+
{
|
|
92
|
+
forceUpdateModel
|
|
93
|
+
}
|
|
94
|
+
) => this.update(sourceModel, replacePreviewModel, fileMatch, forceUpdateModel)));
|
|
95
|
+
this._register(
|
|
96
|
+
this.searchWorkbenchService.searchModel.onReplaceTermChanged(() => this.update(sourceModel, replacePreviewModel, fileMatch))
|
|
97
|
+
);
|
|
73
98
|
this._register(fileMatch.onDispose(() => replacePreviewModel.dispose()));
|
|
74
99
|
this._register(replacePreviewModel.onWillDispose(() => this.dispose()));
|
|
75
100
|
this._register(sourceModel.onWillDispose(() => this.dispose()));
|
|
@@ -81,17 +106,22 @@ let ReplacePreviewModel = class ReplacePreviewModel extends Disposable {
|
|
|
81
106
|
}
|
|
82
107
|
}
|
|
83
108
|
};
|
|
84
|
-
ReplacePreviewModel = ( __decorate([
|
|
85
|
-
( __param(0, IModelService)),
|
|
86
|
-
( __param(1, ILanguageService)),
|
|
87
|
-
( __param(2, ITextModelService)),
|
|
88
|
-
( __param(3, IReplaceService)),
|
|
89
|
-
( __param(4, ISearchViewModelWorkbenchService))
|
|
90
|
-
], ReplacePreviewModel));
|
|
109
|
+
ReplacePreviewModel = ( __decorate([( __param(0, IModelService)), ( __param(1, ILanguageService)), ( __param(2, ITextModelService)), ( __param(3, IReplaceService)), ( __param(4, ISearchViewModelWorkbenchService))], ReplacePreviewModel));
|
|
91
110
|
let ReplaceService = class ReplaceService {
|
|
92
|
-
static {
|
|
93
|
-
|
|
94
|
-
|
|
111
|
+
static {
|
|
112
|
+
ReplaceService_1 = this;
|
|
113
|
+
}
|
|
114
|
+
static {
|
|
115
|
+
this.REPLACE_SAVE_SOURCE = SaveSourceRegistry.registerSource("searchReplace.source", ( localize(10997, "Search and Replace")));
|
|
116
|
+
}
|
|
117
|
+
constructor(
|
|
118
|
+
textFileService,
|
|
119
|
+
editorService,
|
|
120
|
+
textModelResolverService,
|
|
121
|
+
bulkEditorService,
|
|
122
|
+
labelService,
|
|
123
|
+
notebookEditorModelResolverService
|
|
124
|
+
) {
|
|
95
125
|
this.textFileService = textFileService;
|
|
96
126
|
this.editorService = editorService;
|
|
97
127
|
this.textModelResolverService = textModelResolverService;
|
|
@@ -101,24 +131,28 @@ let ReplaceService = class ReplaceService {
|
|
|
101
131
|
}
|
|
102
132
|
async replace(arg, progress = undefined, resource = null) {
|
|
103
133
|
const edits = this.createEdits(arg, resource);
|
|
104
|
-
await this.bulkEditorService.apply(edits, {
|
|
105
|
-
|
|
134
|
+
await this.bulkEditorService.apply(edits, {
|
|
135
|
+
progress
|
|
136
|
+
});
|
|
137
|
+
const rawTextPromises = ( edits.map(async e => {
|
|
106
138
|
if (e.resource.scheme === Schemas.vscodeNotebookCell) {
|
|
107
139
|
const notebookResource = CellUri.parse(e.resource)?.notebook;
|
|
108
140
|
if (notebookResource) {
|
|
109
141
|
let ref;
|
|
110
142
|
try {
|
|
111
143
|
ref = await this.notebookEditorModelResolverService.resolve(notebookResource);
|
|
112
|
-
await ref.object.save({
|
|
113
|
-
|
|
114
|
-
|
|
144
|
+
await ref.object.save({
|
|
145
|
+
source: ReplaceService_1.REPLACE_SAVE_SOURCE
|
|
146
|
+
});
|
|
147
|
+
} finally {
|
|
115
148
|
ref?.dispose();
|
|
116
149
|
}
|
|
117
150
|
}
|
|
118
151
|
return;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
|
|
152
|
+
} else {
|
|
153
|
+
return this.textFileService.files.get(e.resource)?.save({
|
|
154
|
+
source: ReplaceService_1.REPLACE_SAVE_SOURCE
|
|
155
|
+
});
|
|
122
156
|
}
|
|
123
157
|
}));
|
|
124
158
|
return Promises.settled(rawTextPromises);
|
|
@@ -126,10 +160,16 @@ let ReplaceService = class ReplaceService {
|
|
|
126
160
|
async openReplacePreview(element, preserveFocus, sideBySide, pinned) {
|
|
127
161
|
const fileMatch = isSearchTreeMatch(element) ? element.parent() : element;
|
|
128
162
|
const editor = await this.editorService.openEditor({
|
|
129
|
-
original: {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
163
|
+
original: {
|
|
164
|
+
resource: fileMatch.resource
|
|
165
|
+
},
|
|
166
|
+
modified: {
|
|
167
|
+
resource: toReplaceResource(fileMatch.resource)
|
|
168
|
+
},
|
|
169
|
+
label: ( localize(10998, "{0} ↔ {1} (Replace Preview)", fileMatch.name(), fileMatch.name())),
|
|
170
|
+
description: this.labelService.getUriLabel(dirname(fileMatch.resource), {
|
|
171
|
+
relative: true
|
|
172
|
+
}),
|
|
133
173
|
options: {
|
|
134
174
|
preserveFocus,
|
|
135
175
|
pinned,
|
|
@@ -151,21 +191,22 @@ let ReplaceService = class ReplaceService {
|
|
|
151
191
|
}
|
|
152
192
|
async updateReplacePreview(fileMatch, override = false) {
|
|
153
193
|
const replacePreviewUri = toReplaceResource(fileMatch.resource);
|
|
154
|
-
const [sourceModelRef, replaceModelRef] = await Promise.all([
|
|
194
|
+
const [sourceModelRef, replaceModelRef] = await Promise.all([
|
|
195
|
+
this.textModelResolverService.createModelReference(fileMatch.resource),
|
|
196
|
+
this.textModelResolverService.createModelReference(replacePreviewUri)
|
|
197
|
+
]);
|
|
155
198
|
const sourceModel = sourceModelRef.object.textEditorModel;
|
|
156
199
|
const replaceModel = replaceModelRef.object.textEditorModel;
|
|
157
200
|
try {
|
|
158
201
|
if (sourceModel && replaceModel) {
|
|
159
202
|
if (override) {
|
|
160
203
|
replaceModel.setValue(sourceModel.getValue());
|
|
161
|
-
}
|
|
162
|
-
else {
|
|
204
|
+
} else {
|
|
163
205
|
replaceModel.undo();
|
|
164
206
|
}
|
|
165
207
|
this.applyEditsToPreview(fileMatch, replaceModel);
|
|
166
208
|
}
|
|
167
|
-
}
|
|
168
|
-
finally {
|
|
209
|
+
} finally {
|
|
169
210
|
sourceModelRef.dispose();
|
|
170
211
|
replaceModelRef.dispose();
|
|
171
212
|
}
|
|
@@ -174,9 +215,15 @@ let ReplaceService = class ReplaceService {
|
|
|
174
215
|
const resourceEdits = this.createEdits(fileMatch, replaceModel.uri);
|
|
175
216
|
const modelEdits = [];
|
|
176
217
|
for (const resourceEdit of resourceEdits) {
|
|
177
|
-
modelEdits.push(
|
|
218
|
+
modelEdits.push(
|
|
219
|
+
EditOperation.replaceMove(Range.lift(resourceEdit.textEdit.range), resourceEdit.textEdit.text)
|
|
220
|
+
);
|
|
178
221
|
}
|
|
179
|
-
replaceModel.pushEditOperations(
|
|
222
|
+
replaceModel.pushEditOperations(
|
|
223
|
+
[],
|
|
224
|
+
modelEdits.sort((a, b) => Range.compareRangesUsingStarts(a.range, b.range)),
|
|
225
|
+
() => []
|
|
226
|
+
);
|
|
180
227
|
}
|
|
181
228
|
createEdits(arg, resource = null) {
|
|
182
229
|
const edits = [];
|
|
@@ -185,8 +232,7 @@ let ReplaceService = class ReplaceService {
|
|
|
185
232
|
if (isIMatchInNotebook(arg)) {
|
|
186
233
|
const match = arg;
|
|
187
234
|
edits.push(this.createEdit(match, match.replaceString, match.cell?.uri));
|
|
188
|
-
}
|
|
189
|
-
else {
|
|
235
|
+
} else {
|
|
190
236
|
const match = arg;
|
|
191
237
|
edits.push(this.createEdit(match, match.replaceString, resource));
|
|
192
238
|
}
|
|
@@ -207,21 +253,12 @@ let ReplaceService = class ReplaceService {
|
|
|
207
253
|
}
|
|
208
254
|
createEdit(match, text, resource = null) {
|
|
209
255
|
const fileMatch = match.parent();
|
|
210
|
-
return ( new ResourceTextEdit(
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
undefined
|
|
215
|
-
));
|
|
256
|
+
return ( new ResourceTextEdit(resource ?? fileMatch.resource, {
|
|
257
|
+
range: match.range(),
|
|
258
|
+
text
|
|
259
|
+
}, undefined, undefined));
|
|
216
260
|
}
|
|
217
261
|
};
|
|
218
|
-
ReplaceService = ReplaceService_1 = ( __decorate([
|
|
219
|
-
( __param(0, ITextFileService)),
|
|
220
|
-
( __param(1, IEditorService)),
|
|
221
|
-
( __param(2, ITextModelService)),
|
|
222
|
-
( __param(3, IBulkEditService)),
|
|
223
|
-
( __param(4, ILabelService)),
|
|
224
|
-
( __param(5, INotebookEditorModelResolverService))
|
|
225
|
-
], ReplaceService));
|
|
262
|
+
ReplaceService = ReplaceService_1 = ( __decorate([( __param(0, ITextFileService)), ( __param(1, IEditorService)), ( __param(2, ITextModelService)), ( __param(3, IBulkEditService)), ( __param(4, ILabelService)), ( __param(5, INotebookEditorModelResolverService))], ReplaceService));
|
|
226
263
|
|
|
227
264
|
export { ReplacePreviewContentProvider, ReplaceService };
|