@codingame/monaco-vscode-api 1.79.2-next.1 → 1.79.2-next.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/dist/extensions.d.ts +1 -1
- package/dist/extensions.d2.ts +1 -1
- package/dist/extensionsRegistry.d.ts +1 -1
- package/dist/rollup-extension-directory-plugin.d.ts +10 -2
- package/dist/rollup-extension-directory-plugin.js +2 -2
- package/dist/rollup-vsix-plugin.d.ts +10 -2
- package/dist/rollup-vsix-plugin.js +6 -4
- package/dist/services.d.ts +1 -1
- package/dist/views.d.ts +1 -1
- package/dist/vscode/vs/workbench/contrib/search/browser/search.contribution.js +6 -0
- package/dist/vscode/vs/workbench/contrib/search/browser/searchActionsBase.js +30 -1
- package/dist/vscode/vs/workbench/contrib/search/browser/searchActionsCopy.js +204 -0
- package/dist/vscode/vs/workbench/contrib/search/browser/searchActionsFind.js +355 -0
- package/dist/vscode/vs/workbench/contrib/search/browser/searchActionsNav.js +461 -0
- package/dist/vscode/vs/workbench/contrib/search/browser/searchActionsRemoveReplace.js +365 -0
- package/dist/vscode/vs/workbench/contrib/search/browser/searchActionsSymbol.js +37 -0
- package/dist/vscode/vs/workbench/contrib/search/browser/searchActionsTopBar.js +308 -0
- package/dist/vscode/vs/workbench/contrib/search/browser/searchIcons.js +9 -9
- package/dist/vscode/vs/workbench/contrib/search/browser/searchModel.js +33 -2
- package/dist/vscode/vs/workbench/contrib/search/common/constants.js +35 -1
- package/dist/vscode/vs/workbench/services/search/common/queryBuilder.js +44 -2
- package/package.json +1 -1
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
import { dirname } from 'monaco-editor/esm/vs/base/common/resources.js';
|
|
2
|
+
import * as nls from 'monaco-editor/esm/vs/nls.js';
|
|
3
|
+
import { ICommandService } from 'monaco-editor/esm/vs/platform/commands/common/commands.js';
|
|
4
|
+
import { IConfigurationService } from 'monaco-editor/esm/vs/platform/configuration/common/configuration.js';
|
|
5
|
+
import { IListService } from 'monaco-editor/esm/vs/platform/list/browser/listService.js';
|
|
6
|
+
import { IViewsService } from '../../../common/views.js';
|
|
7
|
+
import { RestrictSearchToFolderId, SearchViewVisibleKey, ResourceFolderFocusKey, ExcludeFolderFromSearchId, RevealInSideBarForSearchResults, FileFocusKey, HasSearchResults, FindInFilesActionId, FindInFolderId, FindInWorkspaceId } from '../common/constants.js';
|
|
8
|
+
import { OpenEditorCommandId } from '../../searchEditor/browser/constants.js';
|
|
9
|
+
import { FileMatch, Match } from './searchModel.js';
|
|
10
|
+
import { IEditorService } from '../../../services/editor/common/editorService.js';
|
|
11
|
+
import { ContextKeyExpr } from 'monaco-editor/esm/vs/platform/contextkey/common/contextkey.js';
|
|
12
|
+
import { registerAction2, Action2, MenuId } from 'monaco-editor/esm/vs/platform/actions/common/actions.js';
|
|
13
|
+
import { resolveResourcesForSearchIncludes } from '../../../services/search/common/queryBuilder.js';
|
|
14
|
+
import { IExplorerService, getMultiSelectedResources } from '../../files/browser/files.js';
|
|
15
|
+
import { IFileService } from 'monaco-editor/esm/vs/platform/files/common/files.js';
|
|
16
|
+
import { IWorkspaceContextService } from 'monaco-editor/esm/vs/platform/workspace/common/workspace.js';
|
|
17
|
+
import { VIEWLET_ID, FilesExplorerFocusCondition, ExplorerFolderContext, ExplorerRootContext } from '../../files/common/files.js';
|
|
18
|
+
import { IPaneCompositePartService } from '../../../services/panecomposite/browser/panecomposite.js';
|
|
19
|
+
import { onUnexpectedError } from 'monaco-editor/esm/vs/base/common/errors.js';
|
|
20
|
+
import { category, getSearchView, openSearchView, getElementsToOperateOn } from './searchActionsBase.js';
|
|
21
|
+
import { withNullAsUndefined } from 'monaco-editor/esm/vs/base/common/types.js';
|
|
22
|
+
import { IConfigurationResolverService } from '../../../services/configurationResolver/common/configurationResolver.js';
|
|
23
|
+
import { IHistoryService } from '../../../services/history/common/history.js';
|
|
24
|
+
import { Schemas } from 'monaco-editor/esm/vs/base/common/network.js';
|
|
25
|
+
registerAction2(class RestrictSearchToFolderAction extends Action2 {
|
|
26
|
+
constructor() {
|
|
27
|
+
super({
|
|
28
|
+
id: RestrictSearchToFolderId,
|
|
29
|
+
title: {
|
|
30
|
+
value: ( nls.localize('restrictResultsToFolder', "Restrict Search to Folder")),
|
|
31
|
+
original: 'Restrict Search to Folder'
|
|
32
|
+
},
|
|
33
|
+
category,
|
|
34
|
+
keybinding: {
|
|
35
|
+
weight: 200 ,
|
|
36
|
+
when: ( ContextKeyExpr.and(SearchViewVisibleKey, ResourceFolderFocusKey)),
|
|
37
|
+
primary: 1024 | 512 | 36 ,
|
|
38
|
+
},
|
|
39
|
+
menu: [
|
|
40
|
+
{
|
|
41
|
+
id: MenuId.SearchContext,
|
|
42
|
+
group: 'search',
|
|
43
|
+
order: 3,
|
|
44
|
+
when: ( ContextKeyExpr.and(ResourceFolderFocusKey))
|
|
45
|
+
}
|
|
46
|
+
]
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
async run(accessor, folderMatch) {
|
|
50
|
+
await searchWithFolderCommand(accessor, false, true, undefined, folderMatch);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
registerAction2(class ExcludeFolderFromSearchAction extends Action2 {
|
|
54
|
+
constructor() {
|
|
55
|
+
super({
|
|
56
|
+
id: ExcludeFolderFromSearchId,
|
|
57
|
+
title: {
|
|
58
|
+
value: ( nls.localize('excludeFolderFromSearch', "Exclude Folder from Search")),
|
|
59
|
+
original: 'Exclude Folder from Search'
|
|
60
|
+
},
|
|
61
|
+
category,
|
|
62
|
+
menu: [
|
|
63
|
+
{
|
|
64
|
+
id: MenuId.SearchContext,
|
|
65
|
+
group: 'search',
|
|
66
|
+
order: 4,
|
|
67
|
+
when: ( ContextKeyExpr.and(ResourceFolderFocusKey))
|
|
68
|
+
}
|
|
69
|
+
]
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
async run(accessor, folderMatch) {
|
|
73
|
+
await searchWithFolderCommand(accessor, false, false, undefined, folderMatch);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
registerAction2(class RevealInSideBarForSearchResultsAction extends Action2 {
|
|
77
|
+
constructor() {
|
|
78
|
+
super({
|
|
79
|
+
id: RevealInSideBarForSearchResults,
|
|
80
|
+
title: {
|
|
81
|
+
value: ( nls.localize('revealInSideBar', "Reveal in Explorer View")),
|
|
82
|
+
original: 'Reveal in Explorer View'
|
|
83
|
+
},
|
|
84
|
+
category,
|
|
85
|
+
menu: [{
|
|
86
|
+
id: MenuId.SearchContext,
|
|
87
|
+
when: ( ContextKeyExpr.and(FileFocusKey, HasSearchResults)),
|
|
88
|
+
group: 'search_3',
|
|
89
|
+
order: 1
|
|
90
|
+
}]
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
async run(accessor, args) {
|
|
94
|
+
const paneCompositeService = accessor.get(IPaneCompositePartService);
|
|
95
|
+
const explorerService = accessor.get(IExplorerService);
|
|
96
|
+
const contextService = accessor.get(IWorkspaceContextService);
|
|
97
|
+
const searchView = getSearchView(accessor.get(IViewsService));
|
|
98
|
+
if (!searchView) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
let fileMatch;
|
|
102
|
+
if (!(args instanceof FileMatch)) {
|
|
103
|
+
args = searchView.getControl().getFocus()[0];
|
|
104
|
+
}
|
|
105
|
+
if (args instanceof FileMatch) {
|
|
106
|
+
fileMatch = args;
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
paneCompositeService.openPaneComposite(VIEWLET_ID, 0 , false).then((viewlet) => {
|
|
112
|
+
if (!viewlet) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
const explorerViewContainer = viewlet.getViewPaneContainer();
|
|
116
|
+
const uri = fileMatch.resource;
|
|
117
|
+
if (uri && contextService.isInsideWorkspace(uri)) {
|
|
118
|
+
const explorerView = explorerViewContainer.getExplorerView();
|
|
119
|
+
explorerView.setExpanded(true);
|
|
120
|
+
explorerService.select(uri, true).then(() => explorerView.focus(), onUnexpectedError);
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
registerAction2(class FindInFilesAction extends Action2 {
|
|
126
|
+
constructor() {
|
|
127
|
+
super({
|
|
128
|
+
id: FindInFilesActionId,
|
|
129
|
+
title: {
|
|
130
|
+
value: ( nls.localize('findInFiles', "Find in Files")),
|
|
131
|
+
mnemonicTitle: ( nls.localize(
|
|
132
|
+
{ key: 'miFindInFiles', comment: ['&& denotes a mnemonic'] },
|
|
133
|
+
"Find &&in Files"
|
|
134
|
+
)),
|
|
135
|
+
original: 'Find in Files'
|
|
136
|
+
},
|
|
137
|
+
description: {
|
|
138
|
+
description: ( nls.localize('findInFiles.description', "Open a workspace search")),
|
|
139
|
+
args: [
|
|
140
|
+
{
|
|
141
|
+
name: ( nls.localize('findInFiles.args', "A set of options for the search")),
|
|
142
|
+
schema: {
|
|
143
|
+
type: 'object',
|
|
144
|
+
properties: {
|
|
145
|
+
query: { 'type': 'string' },
|
|
146
|
+
replace: { 'type': 'string' },
|
|
147
|
+
preserveCase: { 'type': 'boolean' },
|
|
148
|
+
triggerSearch: { 'type': 'boolean' },
|
|
149
|
+
filesToInclude: { 'type': 'string' },
|
|
150
|
+
filesToExclude: { 'type': 'string' },
|
|
151
|
+
isRegex: { 'type': 'boolean' },
|
|
152
|
+
isCaseSensitive: { 'type': 'boolean' },
|
|
153
|
+
matchWholeWord: { 'type': 'boolean' },
|
|
154
|
+
useExcludeSettingsAndIgnoreFiles: { 'type': 'boolean' },
|
|
155
|
+
onlyOpenEditors: { 'type': 'boolean' },
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
]
|
|
160
|
+
},
|
|
161
|
+
category,
|
|
162
|
+
keybinding: {
|
|
163
|
+
weight: 200 ,
|
|
164
|
+
primary: 2048 | 1024 | 36 ,
|
|
165
|
+
},
|
|
166
|
+
menu: [{
|
|
167
|
+
id: MenuId.MenubarEditMenu,
|
|
168
|
+
group: '4_find_global',
|
|
169
|
+
order: 1,
|
|
170
|
+
}],
|
|
171
|
+
f1: true
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
async run(accessor, args = {}) {
|
|
175
|
+
findInFilesCommand(accessor, args);
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
registerAction2(class FindInFolderAction extends Action2 {
|
|
179
|
+
constructor() {
|
|
180
|
+
super({
|
|
181
|
+
id: FindInFolderId,
|
|
182
|
+
title: {
|
|
183
|
+
value: ( nls.localize('findInFolder', "Find in Folder...")),
|
|
184
|
+
original: 'Find in Folder...'
|
|
185
|
+
},
|
|
186
|
+
category,
|
|
187
|
+
keybinding: {
|
|
188
|
+
weight: 200 ,
|
|
189
|
+
when: ( ContextKeyExpr.and(FilesExplorerFocusCondition, ExplorerFolderContext)),
|
|
190
|
+
primary: 1024 | 512 | 36 ,
|
|
191
|
+
},
|
|
192
|
+
menu: [
|
|
193
|
+
{
|
|
194
|
+
id: MenuId.ExplorerContext,
|
|
195
|
+
group: '4_search',
|
|
196
|
+
order: 10,
|
|
197
|
+
when: ( ContextKeyExpr.and(ExplorerFolderContext))
|
|
198
|
+
}
|
|
199
|
+
]
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
async run(accessor, resource) {
|
|
203
|
+
await searchWithFolderCommand(accessor, true, true, resource);
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
registerAction2(class FindInWorkspaceAction extends Action2 {
|
|
207
|
+
constructor() {
|
|
208
|
+
super({
|
|
209
|
+
id: FindInWorkspaceId,
|
|
210
|
+
title: {
|
|
211
|
+
value: ( nls.localize('findInWorkspace', "Find in Workspace...")),
|
|
212
|
+
original: 'Find in Workspace...'
|
|
213
|
+
},
|
|
214
|
+
category,
|
|
215
|
+
menu: [
|
|
216
|
+
{
|
|
217
|
+
id: MenuId.ExplorerContext,
|
|
218
|
+
group: '4_search',
|
|
219
|
+
order: 10,
|
|
220
|
+
when: ( ContextKeyExpr.and(ExplorerRootContext, ( ExplorerFolderContext.toNegated())))
|
|
221
|
+
}
|
|
222
|
+
]
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
async run(accessor) {
|
|
226
|
+
const searchConfig = accessor.get(IConfigurationService).getValue().search;
|
|
227
|
+
const mode = searchConfig.mode;
|
|
228
|
+
if (mode === 'view') {
|
|
229
|
+
const searchView = await openSearchView(accessor.get(IViewsService), true);
|
|
230
|
+
searchView?.searchInFolders();
|
|
231
|
+
}
|
|
232
|
+
else {
|
|
233
|
+
return accessor.get(ICommandService).executeCommand(OpenEditorCommandId, {
|
|
234
|
+
location: mode === 'newEditor' ? 'new' : 'reuse',
|
|
235
|
+
filesToInclude: '',
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
async function searchWithFolderCommand(accessor, isFromExplorer, isIncludes, resource, folderMatch) {
|
|
241
|
+
const listService = accessor.get(IListService);
|
|
242
|
+
const fileService = accessor.get(IFileService);
|
|
243
|
+
const viewsService = accessor.get(IViewsService);
|
|
244
|
+
const contextService = accessor.get(IWorkspaceContextService);
|
|
245
|
+
const commandService = accessor.get(ICommandService);
|
|
246
|
+
const searchConfig = accessor.get(IConfigurationService).getValue().search;
|
|
247
|
+
const mode = searchConfig.mode;
|
|
248
|
+
let resources;
|
|
249
|
+
if (isFromExplorer) {
|
|
250
|
+
resources = getMultiSelectedResources(resource, listService, accessor.get(IEditorService), accessor.get(IExplorerService));
|
|
251
|
+
}
|
|
252
|
+
else {
|
|
253
|
+
const searchView = getSearchView(accessor.get(IViewsService));
|
|
254
|
+
if (!searchView) {
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
resources = getMultiSelectedSearchResources(searchView.getControl(), folderMatch, searchConfig);
|
|
258
|
+
}
|
|
259
|
+
const resolvedResources = fileService.resolveAll(( resources.map(resource => ({ resource })))).then(results => {
|
|
260
|
+
const folders = [];
|
|
261
|
+
results.forEach(result => {
|
|
262
|
+
if (result.success && result.stat) {
|
|
263
|
+
folders.push(result.stat.isDirectory ? result.stat.resource : dirname(result.stat.resource));
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
return resolveResourcesForSearchIncludes(folders, contextService);
|
|
267
|
+
});
|
|
268
|
+
if (mode === 'view') {
|
|
269
|
+
const searchView = await openSearchView(viewsService, true);
|
|
270
|
+
if (resources && resources.length && searchView) {
|
|
271
|
+
if (isIncludes) {
|
|
272
|
+
searchView.searchInFolders(await resolvedResources);
|
|
273
|
+
}
|
|
274
|
+
else {
|
|
275
|
+
searchView.searchOutsideOfFolders(await resolvedResources);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
return undefined;
|
|
279
|
+
}
|
|
280
|
+
else {
|
|
281
|
+
if (isIncludes) {
|
|
282
|
+
return commandService.executeCommand(OpenEditorCommandId, {
|
|
283
|
+
filesToInclude: (await resolvedResources).join(', '),
|
|
284
|
+
showIncludesExcludes: true,
|
|
285
|
+
location: mode === 'newEditor' ? 'new' : 'reuse',
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
else {
|
|
289
|
+
return commandService.executeCommand(OpenEditorCommandId, {
|
|
290
|
+
filesToExclude: (await resolvedResources).join(', '),
|
|
291
|
+
showIncludesExcludes: true,
|
|
292
|
+
location: mode === 'newEditor' ? 'new' : 'reuse',
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
function getMultiSelectedSearchResources(viewer, currElement, sortConfig) {
|
|
298
|
+
return ( getElementsToOperateOn(viewer, currElement, sortConfig)
|
|
299
|
+
.map(
|
|
300
|
+
(renderableMatch) => ((renderableMatch instanceof Match) ? null : renderableMatch.resource)
|
|
301
|
+
))
|
|
302
|
+
.filter((renderableMatch) => (renderableMatch !== null));
|
|
303
|
+
}
|
|
304
|
+
async function findInFilesCommand(accessor, _args = {}) {
|
|
305
|
+
const searchConfig = accessor.get(IConfigurationService).getValue().search;
|
|
306
|
+
const viewsService = accessor.get(IViewsService);
|
|
307
|
+
const commandService = accessor.get(ICommandService);
|
|
308
|
+
const args = {};
|
|
309
|
+
if (( Object.keys(_args)).length !== 0) {
|
|
310
|
+
const configurationResolverService = accessor.get(IConfigurationResolverService);
|
|
311
|
+
const historyService = accessor.get(IHistoryService);
|
|
312
|
+
const workspaceContextService = accessor.get(IWorkspaceContextService);
|
|
313
|
+
const activeWorkspaceRootUri = historyService.getLastActiveWorkspaceRoot();
|
|
314
|
+
const filteredActiveWorkspaceRootUri = activeWorkspaceRootUri?.scheme === Schemas.file || activeWorkspaceRootUri?.scheme === Schemas.vscodeRemote ? activeWorkspaceRootUri : undefined;
|
|
315
|
+
const lastActiveWorkspaceRoot = filteredActiveWorkspaceRootUri ? withNullAsUndefined(workspaceContextService.getWorkspaceFolder(filteredActiveWorkspaceRootUri)) : undefined;
|
|
316
|
+
for (const entry of Object.entries(_args)) {
|
|
317
|
+
const name = entry[0];
|
|
318
|
+
const value = entry[1];
|
|
319
|
+
if (value !== undefined) {
|
|
320
|
+
args[name] = (typeof value === 'string') ? await configurationResolverService.resolveAsync(lastActiveWorkspaceRoot, value) : value;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
const mode = searchConfig.mode;
|
|
325
|
+
if (mode === 'view') {
|
|
326
|
+
openSearchView(viewsService, false).then(openedView => {
|
|
327
|
+
if (openedView) {
|
|
328
|
+
const searchAndReplaceWidget = openedView.searchAndReplaceWidget;
|
|
329
|
+
searchAndReplaceWidget.toggleReplace(typeof args.replace === 'string');
|
|
330
|
+
let updatedText = false;
|
|
331
|
+
if (typeof args.query !== 'string') {
|
|
332
|
+
updatedText = openedView.updateTextFromFindWidgetOrSelection({ allowUnselectedWord: typeof args.replace !== 'string' });
|
|
333
|
+
}
|
|
334
|
+
openedView.setSearchParameters(args);
|
|
335
|
+
openedView.searchAndReplaceWidget.focus(undefined, updatedText, updatedText);
|
|
336
|
+
}
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
else {
|
|
340
|
+
const convertArgs = (args) => ({
|
|
341
|
+
location: mode === 'newEditor' ? 'new' : 'reuse',
|
|
342
|
+
query: args.query,
|
|
343
|
+
filesToInclude: args.filesToInclude,
|
|
344
|
+
filesToExclude: args.filesToExclude,
|
|
345
|
+
matchWholeWord: args.matchWholeWord,
|
|
346
|
+
isCaseSensitive: args.isCaseSensitive,
|
|
347
|
+
isRegexp: args.isRegex,
|
|
348
|
+
useExcludeSettingsAndIgnoreFiles: args.useExcludeSettingsAndIgnoreFiles,
|
|
349
|
+
onlyOpenEditors: args.onlyOpenEditors,
|
|
350
|
+
showIncludesExcludes: !!(args.filesToExclude || args.filesToExclude || !args.useExcludeSettingsAndIgnoreFiles),
|
|
351
|
+
});
|
|
352
|
+
commandService.executeCommand(OpenEditorCommandId, convertArgs(args));
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
export { findInFilesCommand };
|