@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,308 @@
|
|
|
1
|
+
import * as nls from 'monaco-editor/esm/vs/nls.js';
|
|
2
|
+
import { WorkbenchListFocusContextKey } from 'monaco-editor/esm/vs/platform/list/browser/listService.js';
|
|
3
|
+
import { IViewsService } from '../../../common/views.js';
|
|
4
|
+
import { searchStopIcon, searchRefreshIcon, searchCollapseAllIcon, searchExpandAllIcon, searchClearIcon, searchShowAsList, searchShowAsTree } from './searchIcons.js';
|
|
5
|
+
import { ClearSearchHistoryCommandId, CancelSearchActionId, SearchViewVisibleKey, RefreshSearchResultsActionId, ViewHasSearchPatternKey, CollapseSearchResultsActionId, HasSearchResults, ViewHasSomeCollapsibleKey, ExpandSearchResultsActionId, ClearSearchResultsActionId, ViewHasReplacePatternKey, ViewHasFilePatternKey, ViewAsTreeActionId, InTreeViewKey, ViewAsListActionId } from '../common/constants.js';
|
|
6
|
+
import { ISearchHistoryService } from '../common/searchHistoryService.js';
|
|
7
|
+
import { FolderMatchWorkspaceRoot, Match, FolderMatch, FolderMatchNoRoot, SearchResult, FileMatch } from './searchModel.js';
|
|
8
|
+
import { VIEW_ID } from '../../../services/search/common/search.js';
|
|
9
|
+
import { ContextKeyExpr } from 'monaco-editor/esm/vs/platform/contextkey/common/contextkey.js';
|
|
10
|
+
import { registerAction2, Action2, MenuId } from 'monaco-editor/esm/vs/platform/actions/common/actions.js';
|
|
11
|
+
import { SearchStateKey, SearchUIState } from '../common/search.js';
|
|
12
|
+
import { category, getSearchView } from './searchActionsBase.js';
|
|
13
|
+
registerAction2(class ClearSearchHistoryCommandAction extends Action2 {
|
|
14
|
+
constructor() {
|
|
15
|
+
super({
|
|
16
|
+
id: ClearSearchHistoryCommandId,
|
|
17
|
+
title: {
|
|
18
|
+
value: ( nls.localize('clearSearchHistoryLabel', "Clear Search History")),
|
|
19
|
+
original: 'Clear Search History'
|
|
20
|
+
},
|
|
21
|
+
category,
|
|
22
|
+
f1: true
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
async run(accessor) {
|
|
26
|
+
clearHistoryCommand(accessor);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
registerAction2(class CancelSearchAction extends Action2 {
|
|
30
|
+
constructor() {
|
|
31
|
+
super({
|
|
32
|
+
id: CancelSearchActionId,
|
|
33
|
+
title: {
|
|
34
|
+
value: ( nls.localize('CancelSearchAction.label', "Cancel Search")),
|
|
35
|
+
original: 'Cancel Search'
|
|
36
|
+
},
|
|
37
|
+
icon: searchStopIcon,
|
|
38
|
+
category,
|
|
39
|
+
f1: true,
|
|
40
|
+
precondition: ( ( SearchStateKey.isEqualTo(SearchUIState.Idle)).negate()),
|
|
41
|
+
keybinding: {
|
|
42
|
+
weight: 200 ,
|
|
43
|
+
when: ( ContextKeyExpr.and(SearchViewVisibleKey, WorkbenchListFocusContextKey)),
|
|
44
|
+
primary: 9 ,
|
|
45
|
+
},
|
|
46
|
+
menu: [{
|
|
47
|
+
id: MenuId.ViewTitle,
|
|
48
|
+
group: 'navigation',
|
|
49
|
+
order: 0,
|
|
50
|
+
when: ( ContextKeyExpr.and(( ContextKeyExpr.equals('view', VIEW_ID)), ( SearchStateKey.isEqualTo(SearchUIState.SlowSearch)))),
|
|
51
|
+
}]
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
run(accessor) {
|
|
55
|
+
return cancelSearch(accessor);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
registerAction2(class RefreshAction extends Action2 {
|
|
59
|
+
constructor() {
|
|
60
|
+
super({
|
|
61
|
+
id: RefreshSearchResultsActionId,
|
|
62
|
+
title: {
|
|
63
|
+
value: ( nls.localize('RefreshAction.label', "Refresh")),
|
|
64
|
+
original: 'Refresh'
|
|
65
|
+
},
|
|
66
|
+
icon: searchRefreshIcon,
|
|
67
|
+
precondition: ViewHasSearchPatternKey,
|
|
68
|
+
category,
|
|
69
|
+
f1: true,
|
|
70
|
+
menu: [{
|
|
71
|
+
id: MenuId.ViewTitle,
|
|
72
|
+
group: 'navigation',
|
|
73
|
+
order: 0,
|
|
74
|
+
when: ( ContextKeyExpr.and(( ContextKeyExpr.equals('view', VIEW_ID)), ( ( SearchStateKey.isEqualTo(SearchUIState.SlowSearch)).negate()))),
|
|
75
|
+
}]
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
run(accessor, ...args) {
|
|
79
|
+
return refreshSearch(accessor);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
registerAction2(class CollapseDeepestExpandedLevelAction extends Action2 {
|
|
83
|
+
constructor() {
|
|
84
|
+
super({
|
|
85
|
+
id: CollapseSearchResultsActionId,
|
|
86
|
+
title: {
|
|
87
|
+
value: ( nls.localize('CollapseDeepestExpandedLevelAction.label', "Collapse All")),
|
|
88
|
+
original: 'Collapse All'
|
|
89
|
+
},
|
|
90
|
+
category,
|
|
91
|
+
icon: searchCollapseAllIcon,
|
|
92
|
+
f1: true,
|
|
93
|
+
precondition: ( ContextKeyExpr.and(HasSearchResults, ViewHasSomeCollapsibleKey)),
|
|
94
|
+
menu: [{
|
|
95
|
+
id: MenuId.ViewTitle,
|
|
96
|
+
group: 'navigation',
|
|
97
|
+
order: 3,
|
|
98
|
+
when: ( ContextKeyExpr.and(( ContextKeyExpr.equals('view', VIEW_ID)), ( ContextKeyExpr.or(( HasSearchResults.negate()), ViewHasSomeCollapsibleKey)))),
|
|
99
|
+
}]
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
run(accessor, ...args) {
|
|
103
|
+
return collapseDeepestExpandedLevel(accessor);
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
registerAction2(class ExpandAllAction extends Action2 {
|
|
107
|
+
constructor() {
|
|
108
|
+
super({
|
|
109
|
+
id: ExpandSearchResultsActionId,
|
|
110
|
+
title: {
|
|
111
|
+
value: ( nls.localize('ExpandAllAction.label', "Expand All")),
|
|
112
|
+
original: 'Expand All'
|
|
113
|
+
},
|
|
114
|
+
category,
|
|
115
|
+
icon: searchExpandAllIcon,
|
|
116
|
+
f1: true,
|
|
117
|
+
precondition: ( ContextKeyExpr.and(HasSearchResults, ( ViewHasSomeCollapsibleKey.toNegated()))),
|
|
118
|
+
menu: [{
|
|
119
|
+
id: MenuId.ViewTitle,
|
|
120
|
+
group: 'navigation',
|
|
121
|
+
order: 3,
|
|
122
|
+
when: ( ContextKeyExpr.and(( ContextKeyExpr.equals('view', VIEW_ID)), HasSearchResults, ( ViewHasSomeCollapsibleKey.toNegated()))),
|
|
123
|
+
}]
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
run(accessor, ...args) {
|
|
127
|
+
return expandAll(accessor);
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
registerAction2(class ClearSearchResultsAction extends Action2 {
|
|
131
|
+
constructor() {
|
|
132
|
+
super({
|
|
133
|
+
id: ClearSearchResultsActionId,
|
|
134
|
+
title: {
|
|
135
|
+
value: ( nls.localize('ClearSearchResultsAction.label', "Clear Search Results")),
|
|
136
|
+
original: 'Clear Search Results'
|
|
137
|
+
},
|
|
138
|
+
category,
|
|
139
|
+
icon: searchClearIcon,
|
|
140
|
+
f1: true,
|
|
141
|
+
precondition: ( ContextKeyExpr.or(
|
|
142
|
+
HasSearchResults,
|
|
143
|
+
ViewHasSearchPatternKey,
|
|
144
|
+
ViewHasReplacePatternKey,
|
|
145
|
+
ViewHasFilePatternKey
|
|
146
|
+
)),
|
|
147
|
+
menu: [{
|
|
148
|
+
id: MenuId.ViewTitle,
|
|
149
|
+
group: 'navigation',
|
|
150
|
+
order: 1,
|
|
151
|
+
when: ( ContextKeyExpr.equals('view', VIEW_ID)),
|
|
152
|
+
}]
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
run(accessor, ...args) {
|
|
156
|
+
return clearSearchResults(accessor);
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
registerAction2(class ViewAsTreeAction extends Action2 {
|
|
160
|
+
constructor() {
|
|
161
|
+
super({
|
|
162
|
+
id: ViewAsTreeActionId,
|
|
163
|
+
title: {
|
|
164
|
+
value: ( nls.localize('ViewAsTreeAction.label', "View as Tree")),
|
|
165
|
+
original: 'View as Tree'
|
|
166
|
+
},
|
|
167
|
+
category,
|
|
168
|
+
icon: searchShowAsList,
|
|
169
|
+
f1: true,
|
|
170
|
+
precondition: ( ContextKeyExpr.and(HasSearchResults, ( InTreeViewKey.toNegated()))),
|
|
171
|
+
menu: [{
|
|
172
|
+
id: MenuId.ViewTitle,
|
|
173
|
+
group: 'navigation',
|
|
174
|
+
order: 2,
|
|
175
|
+
when: ( ContextKeyExpr.and(( ContextKeyExpr.equals('view', VIEW_ID)), ( InTreeViewKey.toNegated()))),
|
|
176
|
+
}]
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
run(accessor, ...args) {
|
|
180
|
+
const searchView = getSearchView(accessor.get(IViewsService));
|
|
181
|
+
if (searchView) {
|
|
182
|
+
searchView.setTreeView(true);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
registerAction2(class ViewAsListAction extends Action2 {
|
|
187
|
+
constructor() {
|
|
188
|
+
super({
|
|
189
|
+
id: ViewAsListActionId,
|
|
190
|
+
title: {
|
|
191
|
+
value: ( nls.localize('ViewAsListAction.label', "View as List")),
|
|
192
|
+
original: 'View as List'
|
|
193
|
+
},
|
|
194
|
+
category,
|
|
195
|
+
icon: searchShowAsTree,
|
|
196
|
+
f1: true,
|
|
197
|
+
precondition: ( ContextKeyExpr.and(HasSearchResults, InTreeViewKey)),
|
|
198
|
+
menu: [{
|
|
199
|
+
id: MenuId.ViewTitle,
|
|
200
|
+
group: 'navigation',
|
|
201
|
+
order: 2,
|
|
202
|
+
when: ( ContextKeyExpr.and(( ContextKeyExpr.equals('view', VIEW_ID)), InTreeViewKey)),
|
|
203
|
+
}]
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
run(accessor, ...args) {
|
|
207
|
+
const searchView = getSearchView(accessor.get(IViewsService));
|
|
208
|
+
if (searchView) {
|
|
209
|
+
searchView.setTreeView(false);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
const clearHistoryCommand = accessor => {
|
|
214
|
+
const searchHistoryService = accessor.get(ISearchHistoryService);
|
|
215
|
+
searchHistoryService.clearHistory();
|
|
216
|
+
};
|
|
217
|
+
function expandAll(accessor) {
|
|
218
|
+
const viewsService = accessor.get(IViewsService);
|
|
219
|
+
const searchView = getSearchView(viewsService);
|
|
220
|
+
if (searchView) {
|
|
221
|
+
const viewer = searchView.getControl();
|
|
222
|
+
viewer.expandAll();
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
function clearSearchResults(accessor) {
|
|
226
|
+
const viewsService = accessor.get(IViewsService);
|
|
227
|
+
const searchView = getSearchView(viewsService);
|
|
228
|
+
searchView?.clearSearchResults();
|
|
229
|
+
}
|
|
230
|
+
function cancelSearch(accessor) {
|
|
231
|
+
const viewsService = accessor.get(IViewsService);
|
|
232
|
+
const searchView = getSearchView(viewsService);
|
|
233
|
+
searchView?.cancelSearch();
|
|
234
|
+
}
|
|
235
|
+
function refreshSearch(accessor) {
|
|
236
|
+
const viewsService = accessor.get(IViewsService);
|
|
237
|
+
const searchView = getSearchView(viewsService);
|
|
238
|
+
searchView?.triggerQueryChange({ preserveFocus: false });
|
|
239
|
+
}
|
|
240
|
+
function collapseDeepestExpandedLevel(accessor) {
|
|
241
|
+
const viewsService = accessor.get(IViewsService);
|
|
242
|
+
const searchView = getSearchView(viewsService);
|
|
243
|
+
if (searchView) {
|
|
244
|
+
const viewer = searchView.getControl();
|
|
245
|
+
const navigator = viewer.navigate();
|
|
246
|
+
let node = navigator.first();
|
|
247
|
+
let canCollapseFileMatchLevel = false;
|
|
248
|
+
let canCollapseFirstLevel = false;
|
|
249
|
+
if (node instanceof FolderMatchWorkspaceRoot || searchView.isTreeLayoutViewVisible) {
|
|
250
|
+
while (node = navigator.next()) {
|
|
251
|
+
if (node instanceof Match) {
|
|
252
|
+
canCollapseFileMatchLevel = true;
|
|
253
|
+
break;
|
|
254
|
+
}
|
|
255
|
+
if (searchView.isTreeLayoutViewVisible && !canCollapseFirstLevel) {
|
|
256
|
+
let nodeToTest = node;
|
|
257
|
+
if (node instanceof FolderMatch) {
|
|
258
|
+
const compressionStartNode = viewer.getCompressedTreeNode(node).element?.elements[0];
|
|
259
|
+
nodeToTest = (compressionStartNode && !(compressionStartNode instanceof Match)) ? compressionStartNode : node;
|
|
260
|
+
}
|
|
261
|
+
const immediateParent = nodeToTest.parent();
|
|
262
|
+
if (!(immediateParent instanceof FolderMatchWorkspaceRoot || immediateParent instanceof FolderMatchNoRoot || immediateParent instanceof SearchResult)) {
|
|
263
|
+
canCollapseFirstLevel = true;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
if (canCollapseFileMatchLevel) {
|
|
269
|
+
node = navigator.first();
|
|
270
|
+
do {
|
|
271
|
+
if (node instanceof FileMatch) {
|
|
272
|
+
viewer.collapse(node);
|
|
273
|
+
}
|
|
274
|
+
} while (node = navigator.next());
|
|
275
|
+
}
|
|
276
|
+
else if (canCollapseFirstLevel) {
|
|
277
|
+
node = navigator.first();
|
|
278
|
+
if (node) {
|
|
279
|
+
do {
|
|
280
|
+
let nodeToTest = node;
|
|
281
|
+
if (node instanceof FolderMatch) {
|
|
282
|
+
const compressionStartNode = viewer.getCompressedTreeNode(node).element?.elements[0];
|
|
283
|
+
nodeToTest = (compressionStartNode && !(compressionStartNode instanceof Match)) ? compressionStartNode : node;
|
|
284
|
+
}
|
|
285
|
+
const immediateParent = nodeToTest.parent();
|
|
286
|
+
if (immediateParent instanceof FolderMatchWorkspaceRoot || immediateParent instanceof FolderMatchNoRoot) {
|
|
287
|
+
if (viewer.hasElement(node)) {
|
|
288
|
+
viewer.collapse(node, true);
|
|
289
|
+
}
|
|
290
|
+
else {
|
|
291
|
+
viewer.collapseAll();
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
} while (node = navigator.next());
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
else {
|
|
298
|
+
viewer.collapseAll();
|
|
299
|
+
}
|
|
300
|
+
const firstFocusParent = viewer.getFocus()[0]?.parent();
|
|
301
|
+
if (firstFocusParent && (firstFocusParent instanceof FolderMatch || firstFocusParent instanceof FileMatch) &&
|
|
302
|
+
viewer.hasElement(firstFocusParent) && viewer.isCollapsed(firstFocusParent)) {
|
|
303
|
+
viewer.domFocus();
|
|
304
|
+
viewer.focusFirst();
|
|
305
|
+
viewer.setSelection(viewer.getFocus());
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
@@ -15,21 +15,21 @@ const searchShowReplaceIcon = registerIcon('search-show-replace', Codicon.chevro
|
|
|
15
15
|
'Icon to expand the replace section in the search view.'
|
|
16
16
|
)));
|
|
17
17
|
const searchReplaceAllIcon = registerIcon('search-replace-all', Codicon.replaceAll, ( localize('searchReplaceAllIcon', 'Icon for replace all in the search view.')));
|
|
18
|
-
registerIcon('search-replace', Codicon.replace, ( localize('searchReplaceIcon', 'Icon for replace in the search view.')));
|
|
19
|
-
registerIcon('search-remove', Codicon.close, ( localize('searchRemoveIcon', 'Icon to remove a search result.')));
|
|
18
|
+
const searchReplaceIcon = registerIcon('search-replace', Codicon.replace, ( localize('searchReplaceIcon', 'Icon for replace in the search view.')));
|
|
19
|
+
const searchRemoveIcon = registerIcon('search-remove', Codicon.close, ( localize('searchRemoveIcon', 'Icon to remove a search result.')));
|
|
20
20
|
const searchRefreshIcon = registerIcon('search-refresh', Codicon.refresh, ( localize('searchRefreshIcon', 'Icon for refresh in the search view.')));
|
|
21
|
-
registerIcon('search-collapse-results', Codicon.collapseAll, ( localize('searchCollapseAllIcon', 'Icon for collapse results in the search view.')));
|
|
22
|
-
registerIcon('search-expand-results', Codicon.expandAll, ( localize('searchExpandAllIcon', 'Icon for expand results in the search view.')));
|
|
23
|
-
registerIcon('search-tree', Codicon.listTree, ( localize(
|
|
21
|
+
const searchCollapseAllIcon = registerIcon('search-collapse-results', Codicon.collapseAll, ( localize('searchCollapseAllIcon', 'Icon for collapse results in the search view.')));
|
|
22
|
+
const searchExpandAllIcon = registerIcon('search-expand-results', Codicon.expandAll, ( localize('searchExpandAllIcon', 'Icon for expand results in the search view.')));
|
|
23
|
+
const searchShowAsTree = registerIcon('search-tree', Codicon.listTree, ( localize(
|
|
24
24
|
'searchShowAsTree',
|
|
25
25
|
'Icon for viewing results as a tree in the search view.'
|
|
26
26
|
)));
|
|
27
|
-
registerIcon('search-list', Codicon.listFlat, ( localize(
|
|
27
|
+
const searchShowAsList = registerIcon('search-list', Codicon.listFlat, ( localize(
|
|
28
28
|
'searchShowAsList',
|
|
29
29
|
'Icon for viewing results as a list in the search view.'
|
|
30
30
|
)));
|
|
31
|
-
registerIcon('search-clear-results', Codicon.clearAll, ( localize('searchClearIcon', 'Icon for clear results in the search view.')));
|
|
32
|
-
registerIcon('search-stop', Codicon.searchStop, ( localize('searchStopIcon', 'Icon for stop in the search view.')));
|
|
31
|
+
const searchClearIcon = registerIcon('search-clear-results', Codicon.clearAll, ( localize('searchClearIcon', 'Icon for clear results in the search view.')));
|
|
32
|
+
const searchStopIcon = registerIcon('search-stop', Codicon.searchStop, ( localize('searchStopIcon', 'Icon for stop in the search view.')));
|
|
33
33
|
const searchViewIcon = registerIcon('search-view-icon', Codicon.search, ( localize('searchViewIcon', 'View icon of the search view.')));
|
|
34
34
|
const searchNewEditorIcon = registerIcon('search-new-editor', Codicon.newFile, ( localize('searchNewEditorIcon', 'Icon for the action to open a new search editor.')));
|
|
35
|
-
export { searchDetailsIcon, searchHideReplaceIcon, searchNewEditorIcon, searchRefreshIcon, searchReplaceAllIcon, searchShowContextIcon, searchShowReplaceIcon, searchViewIcon };
|
|
35
|
+
export { searchClearIcon, searchCollapseAllIcon, searchDetailsIcon, searchExpandAllIcon, searchHideReplaceIcon, searchNewEditorIcon, searchRefreshIcon, searchRemoveIcon, searchReplaceAllIcon, searchReplaceIcon, searchShowAsList, searchShowAsTree, searchShowContextIcon, searchShowReplaceIcon, searchStopIcon, searchViewIcon };
|
|
@@ -33,7 +33,7 @@ import { NotebookCellsChangeType } from '../../notebook/common/notebookCommon.js
|
|
|
33
33
|
import { IReplaceService } from './replace.js';
|
|
34
34
|
import { isIFileMatchWithCells, contentMatchesToTextSearchMatches, webviewMatchesToTextSearchMatches } from './searchNotebookHelpers.js';
|
|
35
35
|
import { ReplacePattern } from '../../../services/search/common/replace.js';
|
|
36
|
-
import {
|
|
36
|
+
import { OneLineRange, resultIsMatch, ISearchService } from '../../../services/search/common/search.js';
|
|
37
37
|
import { editorMatchesToTextSearchResults, addContextToEditorMatches } from '../../../services/search/common/searchHelpers.js';
|
|
38
38
|
class Match {
|
|
39
39
|
constructor(_parent, _fullPreviewLines, _fullPreviewRange, _documentRange) {
|
|
@@ -1186,6 +1186,37 @@ function compareNotebookPos(match1, match2) {
|
|
|
1186
1186
|
return 1;
|
|
1187
1187
|
}
|
|
1188
1188
|
}
|
|
1189
|
+
function searchComparer(elementA, elementB, sortOrder = "default" ) {
|
|
1190
|
+
const elemAParents = createParentList(elementA);
|
|
1191
|
+
const elemBParents = createParentList(elementB);
|
|
1192
|
+
let i = elemAParents.length - 1;
|
|
1193
|
+
let j = elemBParents.length - 1;
|
|
1194
|
+
while (i >= 0 && j >= 0) {
|
|
1195
|
+
if (elemAParents[i].id() !== elemBParents[j].id()) {
|
|
1196
|
+
return searchMatchComparer(elemAParents[i], elemBParents[j], sortOrder);
|
|
1197
|
+
}
|
|
1198
|
+
i--;
|
|
1199
|
+
j--;
|
|
1200
|
+
}
|
|
1201
|
+
const elemAAtEnd = i === 0;
|
|
1202
|
+
const elemBAtEnd = j === 0;
|
|
1203
|
+
if (elemAAtEnd && !elemBAtEnd) {
|
|
1204
|
+
return 1;
|
|
1205
|
+
}
|
|
1206
|
+
else if (!elemAAtEnd && elemBAtEnd) {
|
|
1207
|
+
return -1;
|
|
1208
|
+
}
|
|
1209
|
+
return 0;
|
|
1210
|
+
}
|
|
1211
|
+
function createParentList(element) {
|
|
1212
|
+
const parentArray = [];
|
|
1213
|
+
let currElement = element;
|
|
1214
|
+
while (!(currElement instanceof SearchResult)) {
|
|
1215
|
+
parentArray.push(currElement);
|
|
1216
|
+
currElement = currElement.parent();
|
|
1217
|
+
}
|
|
1218
|
+
return parentArray;
|
|
1219
|
+
}
|
|
1189
1220
|
let SearchResult = class SearchResult extends Disposable {
|
|
1190
1221
|
constructor(_searchModel, replaceService, instantiationService, modelService, uriIdentityService, notebookEditorService) {
|
|
1191
1222
|
super();
|
|
@@ -1839,4 +1870,4 @@ function getFileMatches(matches) {
|
|
|
1839
1870
|
});
|
|
1840
1871
|
return fileMatches.concat(( folderMatches.map(e => e.allDownstreamFileMatches())).flat());
|
|
1841
1872
|
}
|
|
1842
|
-
export { CellMatch, FileMatch, FolderMatch, FolderMatchNoRoot, FolderMatchWithResource, FolderMatchWorkspaceRoot, ISearchWorkbenchService, Match, MatchInNotebook, RangeHighlightDecorations, SearchModel, SearchResult, SearchWorkbenchService, arrayContainsElementOrParent, compareNotebookPos, searchMatchComparer, textSearchMatchesToNotebookMatches };
|
|
1873
|
+
export { CellMatch, FileMatch, FolderMatch, FolderMatchNoRoot, FolderMatchWithResource, FolderMatchWorkspaceRoot, ISearchWorkbenchService, Match, MatchInNotebook, RangeHighlightDecorations, SearchModel, SearchResult, SearchWorkbenchService, arrayContainsElementOrParent, compareNotebookPos, searchComparer, searchMatchComparer, textSearchMatchesToNotebookMatches };
|
|
@@ -1,10 +1,44 @@
|
|
|
1
1
|
import { RawContextKey } from 'monaco-editor/esm/vs/platform/contextkey/common/contextkey.js';
|
|
2
|
+
const FindInFilesActionId = 'workbench.action.findInFiles';
|
|
3
|
+
const FocusSearchFromResults = 'search.action.focusSearchFromResults';
|
|
4
|
+
const OpenMatch = 'search.action.openResult';
|
|
5
|
+
const OpenMatchToSide = 'search.action.openResultToSide';
|
|
6
|
+
const RemoveActionId = 'search.action.remove';
|
|
7
|
+
const CopyPathCommandId = 'search.action.copyPath';
|
|
8
|
+
const CopyMatchCommandId = 'search.action.copyMatch';
|
|
9
|
+
const CopyAllCommandId = 'search.action.copyAll';
|
|
2
10
|
const OpenInEditorCommandId = 'search.action.openInEditor';
|
|
11
|
+
const ClearSearchHistoryCommandId = 'search.action.clearHistory';
|
|
12
|
+
const FocusSearchListCommandID = 'search.action.focusSearchList';
|
|
13
|
+
const ReplaceActionId = 'search.action.replace';
|
|
14
|
+
const ReplaceAllInFileActionId = 'search.action.replaceAllInFile';
|
|
15
|
+
const ReplaceAllInFolderActionId = 'search.action.replaceAllInFolder';
|
|
16
|
+
const CloseReplaceWidgetActionId = 'closeReplaceInFilesWidget';
|
|
3
17
|
const ToggleCaseSensitiveCommandId = 'toggleSearchCaseSensitive';
|
|
4
18
|
const ToggleWholeWordCommandId = 'toggleSearchWholeWord';
|
|
5
19
|
const ToggleRegexCommandId = 'toggleSearchRegex';
|
|
6
20
|
const TogglePreserveCaseId = 'toggleSearchPreserveCase';
|
|
21
|
+
const AddCursorsAtSearchResults = 'addCursorsAtSearchResults';
|
|
22
|
+
const RevealInSideBarForSearchResults = 'search.action.revealInSideBar';
|
|
23
|
+
const ReplaceInFilesActionId = 'workbench.action.replaceInFiles';
|
|
7
24
|
const ShowAllSymbolsActionId = 'workbench.action.showAllSymbols';
|
|
25
|
+
const CancelSearchActionId = 'search.action.cancel';
|
|
26
|
+
const RefreshSearchResultsActionId = 'search.action.refreshSearchResults';
|
|
27
|
+
const FocusNextSearchResultActionId = 'search.action.focusNextSearchResult';
|
|
28
|
+
const FocusPreviousSearchResultActionId = 'search.action.focusPreviousSearchResult';
|
|
29
|
+
const ToggleSearchOnTypeActionId = 'workbench.action.toggleSearchOnType';
|
|
30
|
+
const CollapseSearchResultsActionId = 'search.action.collapseSearchResults';
|
|
31
|
+
const ExpandSearchResultsActionId = 'search.action.expandSearchResults';
|
|
32
|
+
const ClearSearchResultsActionId = 'search.action.clearSearchResults';
|
|
33
|
+
const ViewAsTreeActionId = 'search.action.viewAsTree';
|
|
34
|
+
const ViewAsListActionId = 'search.action.viewAsList';
|
|
35
|
+
const ToggleQueryDetailsActionId = 'workbench.action.search.toggleQueryDetails';
|
|
36
|
+
const ExcludeFolderFromSearchId = 'search.action.excludeFromSearch';
|
|
37
|
+
const FocusNextInputActionId = 'search.focus.nextInputBox';
|
|
38
|
+
const FocusPreviousInputActionId = 'search.focus.previousInputBox';
|
|
39
|
+
const RestrictSearchToFolderId = 'search.action.restrictSearchToFolder';
|
|
40
|
+
const FindInFolderId = 'filesExplorer.findInFolder';
|
|
41
|
+
const FindInWorkspaceId = 'filesExplorer.findInWorkspace';
|
|
8
42
|
const SearchViewVisibleKey = ( new RawContextKey('searchViewletVisible', true));
|
|
9
43
|
const SearchViewFocusedKey = ( new RawContextKey('searchViewletFocus', false));
|
|
10
44
|
const InputBoxFocusedKey = ( new RawContextKey('inputBoxFocus', false));
|
|
@@ -28,4 +62,4 @@ const ViewHasReplacePatternKey = ( new RawContextKey('viewHasReplacePattern', fa
|
|
|
28
62
|
const ViewHasFilePatternKey = ( new RawContextKey('viewHasFilePattern', false));
|
|
29
63
|
const ViewHasSomeCollapsibleKey = ( new RawContextKey('viewHasSomeCollapsibleResult', false));
|
|
30
64
|
const InTreeViewKey = ( new RawContextKey('inTreeView', false));
|
|
31
|
-
export { FileFocusKey, FileMatchOrFolderMatchFocusKey, FileMatchOrFolderMatchWithResourceFocusKey, FileMatchOrMatchFocusKey, FirstMatchFocusKey, FolderFocusKey, HasSearchResults, InTreeViewKey, InputBoxFocusedKey, IsEditableItemKey, MatchFocusKey, OpenInEditorCommandId, PatternExcludesFocusedKey, PatternIncludesFocusedKey, ReplaceActiveKey, ReplaceInputBoxFocusedKey, ResourceFolderFocusKey, SearchInputBoxFocusedKey, SearchViewFocusedKey, SearchViewVisibleKey, ShowAllSymbolsActionId, ToggleCaseSensitiveCommandId, TogglePreserveCaseId, ToggleRegexCommandId, ToggleWholeWordCommandId, ViewHasFilePatternKey, ViewHasReplacePatternKey, ViewHasSearchPatternKey, ViewHasSomeCollapsibleKey };
|
|
65
|
+
export { AddCursorsAtSearchResults, CancelSearchActionId, ClearSearchHistoryCommandId, ClearSearchResultsActionId, CloseReplaceWidgetActionId, CollapseSearchResultsActionId, CopyAllCommandId, CopyMatchCommandId, CopyPathCommandId, ExcludeFolderFromSearchId, ExpandSearchResultsActionId, FileFocusKey, FileMatchOrFolderMatchFocusKey, FileMatchOrFolderMatchWithResourceFocusKey, FileMatchOrMatchFocusKey, FindInFilesActionId, FindInFolderId, FindInWorkspaceId, FirstMatchFocusKey, FocusNextInputActionId, FocusNextSearchResultActionId, FocusPreviousInputActionId, FocusPreviousSearchResultActionId, FocusSearchFromResults, FocusSearchListCommandID, FolderFocusKey, HasSearchResults, InTreeViewKey, InputBoxFocusedKey, IsEditableItemKey, MatchFocusKey, OpenInEditorCommandId, OpenMatch, OpenMatchToSide, PatternExcludesFocusedKey, PatternIncludesFocusedKey, RefreshSearchResultsActionId, RemoveActionId, ReplaceActionId, ReplaceActiveKey, ReplaceAllInFileActionId, ReplaceAllInFolderActionId, ReplaceInFilesActionId, ReplaceInputBoxFocusedKey, ResourceFolderFocusKey, RestrictSearchToFolderId, RevealInSideBarForSearchResults, SearchInputBoxFocusedKey, SearchViewFocusedKey, SearchViewVisibleKey, ShowAllSymbolsActionId, ToggleCaseSensitiveCommandId, TogglePreserveCaseId, ToggleQueryDetailsActionId, ToggleRegexCommandId, ToggleSearchOnTypeActionId, ToggleWholeWordCommandId, ViewAsListActionId, ViewAsTreeActionId, ViewHasFilePatternKey, ViewHasReplacePatternKey, ViewHasSearchPatternKey, ViewHasSomeCollapsibleKey };
|
|
@@ -6,7 +6,7 @@ import { untildify } from 'monaco-editor/esm/vs/base/common/labels.js';
|
|
|
6
6
|
import { ResourceMap } from 'monaco-editor/esm/vs/base/common/map.js';
|
|
7
7
|
import { Schemas } from 'monaco-editor/esm/vs/base/common/network.js';
|
|
8
8
|
import * as path from 'monaco-editor/esm/vs/base/common/path.js';
|
|
9
|
-
import { isAbsolutePath, isEqual, basename } from 'monaco-editor/esm/vs/base/common/resources.js';
|
|
9
|
+
import { relativePath, isAbsolutePath, isEqual, basename } from 'monaco-editor/esm/vs/base/common/resources.js';
|
|
10
10
|
import * as strings from 'monaco-editor/esm/vs/base/common/strings.js';
|
|
11
11
|
import { assertIsDefined, isDefined } from 'monaco-editor/esm/vs/base/common/types.js';
|
|
12
12
|
import { URI } from 'monaco-editor/esm/vs/base/common/uri.js';
|
|
@@ -449,4 +449,46 @@ function normalizeGlobPattern(pattern) {
|
|
|
449
449
|
.replace(/^\.\//, '')
|
|
450
450
|
.replace(/\/+$/g, '');
|
|
451
451
|
}
|
|
452
|
-
|
|
452
|
+
function escapeGlobPattern(path) {
|
|
453
|
+
return path.replace(/([?*[\]])/g, '[$1]');
|
|
454
|
+
}
|
|
455
|
+
function resolveResourcesForSearchIncludes(resources, contextService) {
|
|
456
|
+
resources = arrays.distinct(resources, resource => ( resource.toString()));
|
|
457
|
+
const folderPaths = [];
|
|
458
|
+
const workspace = contextService.getWorkspace();
|
|
459
|
+
if (resources) {
|
|
460
|
+
resources.forEach(resource => {
|
|
461
|
+
let folderPath;
|
|
462
|
+
if (contextService.getWorkbenchState() === 2 ) {
|
|
463
|
+
folderPath = relativePath(workspace.folders[0].uri, resource);
|
|
464
|
+
if (folderPath && folderPath !== '.') {
|
|
465
|
+
folderPath = './' + folderPath;
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
else {
|
|
469
|
+
const owningFolder = contextService.getWorkspaceFolder(resource);
|
|
470
|
+
if (owningFolder) {
|
|
471
|
+
const owningRootName = owningFolder.name;
|
|
472
|
+
const isUniqueFolder = workspace.folders.filter(folder => folder.name === owningRootName).length === 1;
|
|
473
|
+
if (isUniqueFolder) {
|
|
474
|
+
const relPath = relativePath(owningFolder.uri, resource);
|
|
475
|
+
if (relPath === '') {
|
|
476
|
+
folderPath = `./${owningFolder.name}`;
|
|
477
|
+
}
|
|
478
|
+
else {
|
|
479
|
+
folderPath = `./${owningFolder.name}/${relPath}`;
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
else {
|
|
483
|
+
folderPath = resource.fsPath;
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
if (folderPath) {
|
|
488
|
+
folderPaths.push(escapeGlobPattern(folderPath));
|
|
489
|
+
}
|
|
490
|
+
});
|
|
491
|
+
}
|
|
492
|
+
return folderPaths;
|
|
493
|
+
}
|
|
494
|
+
export { QueryBuilder, resolveResourcesForSearchIncludes };
|