@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.
- package/package.json +2 -2
- package/search.js +4 -4
- package/external/rollup-plugin-styles/dist/runtime/inject-css.js +0 -3
- package/external/tslib/tslib.es6.js +0 -11
- package/override/vs/platform/dialogs/common/dialogs.js +0 -8
- package/vscode/src/vs/workbench/contrib/search/browser/anythingQuickAccess.js +0 -776
- package/vscode/src/vs/workbench/contrib/search/browser/media/anythingQuickAccess.css.js +0 -6
- package/vscode/src/vs/workbench/contrib/search/browser/media/searchview.css.js +0 -6
- package/vscode/src/vs/workbench/contrib/search/browser/patternInputWidget.js +0 -231
- package/vscode/src/vs/workbench/contrib/search/browser/quickTextSearch/textSearchQuickAccess.js +0 -342
- package/vscode/src/vs/workbench/contrib/search/browser/replaceContributions.js +0 -8
- package/vscode/src/vs/workbench/contrib/search/browser/replaceService.js +0 -232
- package/vscode/src/vs/workbench/contrib/search/browser/search.contribution.js +0 -621
- package/vscode/src/vs/workbench/contrib/search/browser/searchActionsCopy.js +0 -209
- package/vscode/src/vs/workbench/contrib/search/browser/searchActionsNav.js +0 -511
- package/vscode/src/vs/workbench/contrib/search/browser/searchActionsRemoveReplace.js +0 -374
- package/vscode/src/vs/workbench/contrib/search/browser/searchActionsSymbol.js +0 -43
- package/vscode/src/vs/workbench/contrib/search/browser/searchActionsTextQuickAccess.js +0 -44
- package/vscode/src/vs/workbench/contrib/search/browser/searchActionsTopBar.js +0 -323
- package/vscode/src/vs/workbench/contrib/search/browser/searchFindInput.js +0 -47
- package/vscode/src/vs/workbench/contrib/search/browser/searchIcons.js +0 -96
- package/vscode/src/vs/workbench/contrib/search/browser/searchMessage.js +0 -66
- package/vscode/src/vs/workbench/contrib/search/browser/searchResultsView.js +0 -434
- package/vscode/src/vs/workbench/contrib/search/browser/searchView.js +0 -2096
- package/vscode/src/vs/workbench/contrib/search/browser/searchWidget.js +0 -667
- package/vscode/src/vs/workbench/contrib/search/browser/symbolsQuickAccess.js +0 -234
- package/vscode/src/vs/workbench/contrib/search/common/cacheState.js +0 -87
- package/vscode/src/vs/workbench/contrib/searchEditor/browser/media/searchEditor.css.js +0 -6
- package/vscode/src/vs/workbench/contrib/searchEditor/browser/searchEditor.contribution.js +0 -586
- package/vscode/src/vs/workbench/contrib/searchEditor/browser/searchEditor.js +0 -736
- package/vscode/src/vs/workbench/contrib/searchEditor/browser/searchEditorActions.js +0 -189
- package/vscode/src/vs/workbench/contrib/searchEditor/browser/searchEditorInput.js +0 -320
- package/vscode/src/vs/workbench/contrib/searchEditor/browser/searchEditorModel.js +0 -138
- package/vscode/src/vs/workbench/contrib/searchEditor/browser/searchEditorSerialization.js +0 -293
- package/vscode/src/vs/workbench/services/search/common/searchService.js +0 -372
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
import { Schemas } from 'vscode/vscode/vs/base/common/network';
|
|
2
|
-
import './media/searchEditor.css.js';
|
|
3
|
-
import { isDiffEditor } from 'vscode/vscode/vs/editor/browser/editorBrowser';
|
|
4
|
-
import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration';
|
|
5
|
-
import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
6
|
-
import { ILabelService } from 'vscode/vscode/vs/platform/label/common/label';
|
|
7
|
-
import { ITelemetryService } from 'vscode/vscode/vs/platform/telemetry/common/telemetry';
|
|
8
|
-
import { IWorkspaceContextService } from 'vscode/vscode/vs/platform/workspace/common/workspace';
|
|
9
|
-
import { IViewsService } from 'vscode/vscode/vs/workbench/services/views/common/viewsService';
|
|
10
|
-
import { getSearchView } from 'vscode/vscode/vs/workbench/contrib/search/browser/searchActionsBase';
|
|
11
|
-
import { SearchEditorInput, getOrMakeSearchEditorInput } from './searchEditorInput.js';
|
|
12
|
-
import { serializeSearchResultForEditor } from './searchEditorSerialization.js';
|
|
13
|
-
import { IConfigurationResolverService } from 'vscode/vscode/vs/workbench/services/configurationResolver/common/configurationResolver';
|
|
14
|
-
import { IEditorGroupsService } from 'vscode/vscode/vs/workbench/services/editor/common/editorGroupsService';
|
|
15
|
-
import { IEditorService, SIDE_GROUP, ACTIVE_GROUP } from 'vscode/vscode/vs/workbench/services/editor/common/editorService';
|
|
16
|
-
import { IHistoryService } from 'vscode/vscode/vs/workbench/services/history/common/history';
|
|
17
|
-
|
|
18
|
-
const toggleSearchEditorCaseSensitiveCommand = (accessor) => {
|
|
19
|
-
const editorService = accessor.get(IEditorService);
|
|
20
|
-
const input = editorService.activeEditor;
|
|
21
|
-
if (input instanceof SearchEditorInput) {
|
|
22
|
-
editorService.activeEditorPane.toggleCaseSensitive();
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
const toggleSearchEditorWholeWordCommand = (accessor) => {
|
|
26
|
-
const editorService = accessor.get(IEditorService);
|
|
27
|
-
const input = editorService.activeEditor;
|
|
28
|
-
if (input instanceof SearchEditorInput) {
|
|
29
|
-
editorService.activeEditorPane.toggleWholeWords();
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
const toggleSearchEditorRegexCommand = (accessor) => {
|
|
33
|
-
const editorService = accessor.get(IEditorService);
|
|
34
|
-
const input = editorService.activeEditor;
|
|
35
|
-
if (input instanceof SearchEditorInput) {
|
|
36
|
-
editorService.activeEditorPane.toggleRegex();
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
const toggleSearchEditorContextLinesCommand = (accessor) => {
|
|
40
|
-
const editorService = accessor.get(IEditorService);
|
|
41
|
-
const input = editorService.activeEditor;
|
|
42
|
-
if (input instanceof SearchEditorInput) {
|
|
43
|
-
editorService.activeEditorPane.toggleContextLines();
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
const modifySearchEditorContextLinesCommand = (accessor, increase) => {
|
|
47
|
-
const editorService = accessor.get(IEditorService);
|
|
48
|
-
const input = editorService.activeEditor;
|
|
49
|
-
if (input instanceof SearchEditorInput) {
|
|
50
|
-
editorService.activeEditorPane.modifyContextLines(increase);
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
const selectAllSearchEditorMatchesCommand = (accessor) => {
|
|
54
|
-
const editorService = accessor.get(IEditorService);
|
|
55
|
-
const input = editorService.activeEditor;
|
|
56
|
-
if (input instanceof SearchEditorInput) {
|
|
57
|
-
editorService.activeEditorPane.focusAllResults();
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
async function openSearchEditor(accessor) {
|
|
61
|
-
const viewsService = accessor.get(IViewsService);
|
|
62
|
-
const instantiationService = accessor.get(IInstantiationService);
|
|
63
|
-
const searchView = getSearchView(viewsService);
|
|
64
|
-
if (searchView) {
|
|
65
|
-
await instantiationService.invokeFunction(openNewSearchEditor, {
|
|
66
|
-
filesToInclude: searchView.searchIncludePattern.getValue(),
|
|
67
|
-
onlyOpenEditors: searchView.searchIncludePattern.onlySearchInOpenEditors(),
|
|
68
|
-
filesToExclude: searchView.searchExcludePattern.getValue(),
|
|
69
|
-
isRegexp: searchView.searchAndReplaceWidget.searchInput?.getRegex(),
|
|
70
|
-
isCaseSensitive: searchView.searchAndReplaceWidget.searchInput?.getCaseSensitive(),
|
|
71
|
-
matchWholeWord: searchView.searchAndReplaceWidget.searchInput?.getWholeWords(),
|
|
72
|
-
useExcludeSettingsAndIgnoreFiles: searchView.searchExcludePattern.useExcludesAndIgnoreFiles(),
|
|
73
|
-
showIncludesExcludes: !!(searchView.searchIncludePattern.getValue() || searchView.searchExcludePattern.getValue() || !searchView.searchExcludePattern.useExcludesAndIgnoreFiles())
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
else {
|
|
77
|
-
await instantiationService.invokeFunction(openNewSearchEditor);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
const openNewSearchEditor = async (accessor, _args = {}, toSide = false) => {
|
|
81
|
-
const editorService = accessor.get(IEditorService);
|
|
82
|
-
const editorGroupsService = accessor.get(IEditorGroupsService);
|
|
83
|
-
const telemetryService = accessor.get(ITelemetryService);
|
|
84
|
-
const instantiationService = accessor.get(IInstantiationService);
|
|
85
|
-
const configurationService = accessor.get(IConfigurationService);
|
|
86
|
-
const configurationResolverService = accessor.get(IConfigurationResolverService);
|
|
87
|
-
const workspaceContextService = accessor.get(IWorkspaceContextService);
|
|
88
|
-
const historyService = accessor.get(IHistoryService);
|
|
89
|
-
const activeWorkspaceRootUri = historyService.getLastActiveWorkspaceRoot(Schemas.file);
|
|
90
|
-
const lastActiveWorkspaceRoot = activeWorkspaceRootUri ? workspaceContextService.getWorkspaceFolder(activeWorkspaceRootUri) ?? undefined : undefined;
|
|
91
|
-
const activeEditorControl = editorService.activeTextEditorControl;
|
|
92
|
-
let activeModel;
|
|
93
|
-
let selected = '';
|
|
94
|
-
if (activeEditorControl) {
|
|
95
|
-
if (isDiffEditor(activeEditorControl)) {
|
|
96
|
-
if (activeEditorControl.getOriginalEditor().hasTextFocus()) {
|
|
97
|
-
activeModel = activeEditorControl.getOriginalEditor();
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
activeModel = activeEditorControl.getModifiedEditor();
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
104
|
-
activeModel = activeEditorControl;
|
|
105
|
-
}
|
|
106
|
-
const selection = activeModel?.getSelection();
|
|
107
|
-
selected = (selection && activeModel?.getModel()?.getValueInRange(selection)) ?? '';
|
|
108
|
-
if (selection?.isEmpty() && configurationService.getValue('search').seedWithNearestWord) {
|
|
109
|
-
const wordAtPosition = activeModel.getModel()?.getWordAtPosition(selection.getStartPosition());
|
|
110
|
-
if (wordAtPosition) {
|
|
111
|
-
selected = wordAtPosition.word;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
else {
|
|
116
|
-
if (editorService.activeEditor instanceof SearchEditorInput) {
|
|
117
|
-
const active = editorService.activeEditorPane;
|
|
118
|
-
selected = active.getSelected();
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
telemetryService.publicLog2('searchEditor/openNewSearchEditor');
|
|
122
|
-
const seedSearchStringFromSelection = _args.location === 'new' || configurationService.getValue('editor').find.seedSearchStringFromSelection;
|
|
123
|
-
const args = { query: seedSearchStringFromSelection ? selected : undefined };
|
|
124
|
-
for (const entry of Object.entries(_args)) {
|
|
125
|
-
const name = entry[0];
|
|
126
|
-
const value = entry[1];
|
|
127
|
-
if (value !== undefined) {
|
|
128
|
-
args[name] = (typeof value === 'string') ? await configurationResolverService.resolveAsync(lastActiveWorkspaceRoot, value) : value;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
const existing = editorService.getEditors(0 ).find(id => id.editor.typeId === SearchEditorInput.ID);
|
|
132
|
-
let editor;
|
|
133
|
-
if (existing && args.location === 'reuse') {
|
|
134
|
-
const group = editorGroupsService.getGroup(existing.groupId);
|
|
135
|
-
if (!group) {
|
|
136
|
-
throw new Error('Invalid group id for search editor');
|
|
137
|
-
}
|
|
138
|
-
const input = existing.editor;
|
|
139
|
-
editor = (await group.openEditor(input));
|
|
140
|
-
if (selected) {
|
|
141
|
-
editor.setQuery(selected);
|
|
142
|
-
}
|
|
143
|
-
else {
|
|
144
|
-
editor.selectQuery();
|
|
145
|
-
}
|
|
146
|
-
editor.setSearchConfig(args);
|
|
147
|
-
}
|
|
148
|
-
else {
|
|
149
|
-
const input = instantiationService.invokeFunction(getOrMakeSearchEditorInput, { config: args, resultsContents: '', from: 'rawData' });
|
|
150
|
-
editor = await editorService.openEditor(input, { pinned: true }, toSide ? SIDE_GROUP : ACTIVE_GROUP);
|
|
151
|
-
}
|
|
152
|
-
const searchOnType = configurationService.getValue('search').searchOnType;
|
|
153
|
-
if (args.triggerSearch === true ||
|
|
154
|
-
args.triggerSearch !== false && searchOnType && args.query) {
|
|
155
|
-
editor.triggerSearch({ focusResults: args.focusResults });
|
|
156
|
-
}
|
|
157
|
-
if (!args.focusResults) {
|
|
158
|
-
editor.focusSearchInput();
|
|
159
|
-
}
|
|
160
|
-
};
|
|
161
|
-
const createEditorFromSearchResult = async (accessor, searchResult, rawIncludePattern, rawExcludePattern, onlySearchInOpenEditors) => {
|
|
162
|
-
if (!searchResult.query) {
|
|
163
|
-
console.error('Expected searchResult.query to be defined. Got', searchResult);
|
|
164
|
-
return;
|
|
165
|
-
}
|
|
166
|
-
const editorService = accessor.get(IEditorService);
|
|
167
|
-
const telemetryService = accessor.get(ITelemetryService);
|
|
168
|
-
const instantiationService = accessor.get(IInstantiationService);
|
|
169
|
-
const labelService = accessor.get(ILabelService);
|
|
170
|
-
const configurationService = accessor.get(IConfigurationService);
|
|
171
|
-
const sortOrder = configurationService.getValue('search').sortOrder;
|
|
172
|
-
telemetryService.publicLog2('searchEditor/createEditorFromSearchResult');
|
|
173
|
-
const labelFormatter = (uri) => labelService.getUriLabel(uri, { relative: true });
|
|
174
|
-
const { text, matchRanges, config } = serializeSearchResultForEditor(searchResult, rawIncludePattern, rawExcludePattern, 0, labelFormatter, sortOrder);
|
|
175
|
-
config.onlyOpenEditors = onlySearchInOpenEditors;
|
|
176
|
-
const contextLines = configurationService.getValue('search').searchEditor.defaultNumberOfContextLines;
|
|
177
|
-
if (searchResult.isDirty || contextLines === 0 || contextLines === null) {
|
|
178
|
-
const input = instantiationService.invokeFunction(getOrMakeSearchEditorInput, { resultsContents: text, config, from: 'rawData' });
|
|
179
|
-
await editorService.openEditor(input, { pinned: true });
|
|
180
|
-
input.setMatchRanges(matchRanges);
|
|
181
|
-
}
|
|
182
|
-
else {
|
|
183
|
-
const input = instantiationService.invokeFunction(getOrMakeSearchEditorInput, { from: 'rawData', resultsContents: '', config: { ...config, contextLines } });
|
|
184
|
-
const editor = await editorService.openEditor(input, { pinned: true });
|
|
185
|
-
editor.triggerSearch({ focusResults: true });
|
|
186
|
-
}
|
|
187
|
-
};
|
|
188
|
-
|
|
189
|
-
export { createEditorFromSearchResult, modifySearchEditorContextLinesCommand, openNewSearchEditor, openSearchEditor, selectAllSearchEditorMatchesCommand, toggleSearchEditorCaseSensitiveCommand, toggleSearchEditorContextLinesCommand, toggleSearchEditorRegexCommand, toggleSearchEditorWholeWordCommand };
|
|
@@ -1,320 +0,0 @@
|
|
|
1
|
-
import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
-
import './media/searchEditor.css.js';
|
|
3
|
-
import { Emitter } from 'vscode/vscode/vs/base/common/event';
|
|
4
|
-
import { basename } from 'vscode/vscode/vs/base/common/path';
|
|
5
|
-
import { isEqual, extname, joinPath } from 'vscode/vscode/vs/base/common/resources';
|
|
6
|
-
import { URI } from 'vscode/vscode/vs/base/common/uri';
|
|
7
|
-
import { IModelService } from 'vscode/vscode/vs/editor/common/services/model';
|
|
8
|
-
import { localizeWithPath } from 'vscode/vscode/vs/nls';
|
|
9
|
-
import '../../../../../../../override/vs/platform/dialogs/common/dialogs.js';
|
|
10
|
-
import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
11
|
-
import { IStorageService } from 'vscode/vscode/vs/platform/storage/common/storage';
|
|
12
|
-
import { ITelemetryService } from 'vscode/vscode/vs/platform/telemetry/common/telemetry';
|
|
13
|
-
import { EditorResourceAccessor } from 'vscode/vscode/vs/workbench/common/editor';
|
|
14
|
-
import { Memento } from 'vscode/vscode/vs/workbench/common/memento';
|
|
15
|
-
import { SearchEditorInputTypeId, SearchEditorScheme, SearchEditorWorkingCopyTypeId, SearchEditorFindMatchClass } from 'vscode/vscode/vs/workbench/contrib/searchEditor/browser/constants';
|
|
16
|
-
import { SearchEditorModel, searchEditorModelFactory } from './searchEditorModel.js';
|
|
17
|
-
import { serializeSearchConfiguration, parseSavedSearchEditor, defaultSearchConfig } from './searchEditorSerialization.js';
|
|
18
|
-
import { IPathService } from 'vscode/vscode/vs/workbench/services/path/common/pathService';
|
|
19
|
-
import { ITextFileService } from 'vscode/vscode/vs/workbench/services/textfile/common/textfiles';
|
|
20
|
-
import { IWorkingCopyService } from 'vscode/vscode/vs/workbench/services/workingCopy/common/workingCopyService';
|
|
21
|
-
import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration';
|
|
22
|
-
import { bufferToReadable, VSBuffer } from 'vscode/vscode/vs/base/common/buffer';
|
|
23
|
-
import { EditorInput } from 'vscode/vscode/vs/workbench/common/editor/editorInput';
|
|
24
|
-
import { Codicon } from 'vscode/vscode/vs/base/common/codicons';
|
|
25
|
-
import { registerIcon } from 'vscode/vscode/vs/platform/theme/common/iconRegistry';
|
|
26
|
-
import { IFileDialogService } from 'vscode/vscode/vs/platform/dialogs/common/dialogs';
|
|
27
|
-
|
|
28
|
-
var SearchEditorInput_1;
|
|
29
|
-
const SEARCH_EDITOR_EXT = '.code-search';
|
|
30
|
-
const SearchEditorIcon = registerIcon('search-editor-label-icon', Codicon.search, ( localizeWithPath(
|
|
31
|
-
'vs/workbench/contrib/searchEditor/browser/searchEditorInput',
|
|
32
|
-
'searchEditorLabelIcon',
|
|
33
|
-
'Icon of the search editor label.'
|
|
34
|
-
)));
|
|
35
|
-
let SearchEditorInput = class SearchEditorInput extends EditorInput {
|
|
36
|
-
static { SearchEditorInput_1 = this; }
|
|
37
|
-
static { this.ID = SearchEditorInputTypeId; }
|
|
38
|
-
get typeId() {
|
|
39
|
-
return SearchEditorInput_1.ID;
|
|
40
|
-
}
|
|
41
|
-
get editorId() {
|
|
42
|
-
return this.typeId;
|
|
43
|
-
}
|
|
44
|
-
getIcon() {
|
|
45
|
-
return SearchEditorIcon;
|
|
46
|
-
}
|
|
47
|
-
get capabilities() {
|
|
48
|
-
let capabilities = 8 ;
|
|
49
|
-
if (!this.backingUri) {
|
|
50
|
-
capabilities |= 4 ;
|
|
51
|
-
}
|
|
52
|
-
return capabilities;
|
|
53
|
-
}
|
|
54
|
-
get resource() {
|
|
55
|
-
return this.backingUri || this.modelUri;
|
|
56
|
-
}
|
|
57
|
-
constructor(modelUri, backingUri, modelService, textFileService, fileDialogService, instantiationService, workingCopyService, telemetryService, pathService, storageService) {
|
|
58
|
-
super();
|
|
59
|
-
this.modelUri = modelUri;
|
|
60
|
-
this.backingUri = backingUri;
|
|
61
|
-
this.modelService = modelService;
|
|
62
|
-
this.textFileService = textFileService;
|
|
63
|
-
this.fileDialogService = fileDialogService;
|
|
64
|
-
this.instantiationService = instantiationService;
|
|
65
|
-
this.workingCopyService = workingCopyService;
|
|
66
|
-
this.telemetryService = telemetryService;
|
|
67
|
-
this.pathService = pathService;
|
|
68
|
-
this.dirty = false;
|
|
69
|
-
this._onDidChangeContent = this._register(( new Emitter()));
|
|
70
|
-
this.onDidChangeContent = this._onDidChangeContent.event;
|
|
71
|
-
this._onDidSave = this._register(( new Emitter()));
|
|
72
|
-
this.onDidSave = this._onDidSave.event;
|
|
73
|
-
this.oldDecorationsIDs = [];
|
|
74
|
-
this.model = instantiationService.createInstance(SearchEditorModel, modelUri);
|
|
75
|
-
if (this.modelUri.scheme !== SearchEditorScheme) {
|
|
76
|
-
throw Error('SearchEditorInput must be invoked with a SearchEditorScheme uri');
|
|
77
|
-
}
|
|
78
|
-
this.memento = ( new Memento(SearchEditorInput_1.ID, storageService));
|
|
79
|
-
storageService.onWillSaveState(() => this.memento.saveMemento());
|
|
80
|
-
const input = this;
|
|
81
|
-
const workingCopyAdapter = new (class {
|
|
82
|
-
constructor() {
|
|
83
|
-
this.typeId = SearchEditorWorkingCopyTypeId;
|
|
84
|
-
this.resource = input.modelUri;
|
|
85
|
-
this.capabilities = input.hasCapability(4 ) ? 2 : 0 ;
|
|
86
|
-
this.onDidChangeDirty = input.onDidChangeDirty;
|
|
87
|
-
this.onDidChangeContent = input.onDidChangeContent;
|
|
88
|
-
this.onDidSave = input.onDidSave;
|
|
89
|
-
}
|
|
90
|
-
get name() { return input.getName(); }
|
|
91
|
-
isDirty() { return input.isDirty(); }
|
|
92
|
-
isModified() { return input.isDirty(); }
|
|
93
|
-
backup(token) { return input.backup(token); }
|
|
94
|
-
save(options) { return input.save(0, options).then(editor => !!editor); }
|
|
95
|
-
revert(options) { return input.revert(0, options); }
|
|
96
|
-
});
|
|
97
|
-
this._register(this.workingCopyService.registerWorkingCopy(workingCopyAdapter));
|
|
98
|
-
}
|
|
99
|
-
async save(group, options) {
|
|
100
|
-
if (((await this.resolveModels()).resultsModel).isDisposed()) {
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
if (this.backingUri) {
|
|
104
|
-
await this.textFileService.write(this.backingUri, await this.serializeForDisk(), options);
|
|
105
|
-
this.setDirty(false);
|
|
106
|
-
this._onDidSave.fire({ reason: options?.reason, source: options?.source });
|
|
107
|
-
return this;
|
|
108
|
-
}
|
|
109
|
-
else {
|
|
110
|
-
return this.saveAs(group, options);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
tryReadConfigSync() {
|
|
114
|
-
return this._cachedConfigurationModel?.config;
|
|
115
|
-
}
|
|
116
|
-
async serializeForDisk() {
|
|
117
|
-
const { configurationModel, resultsModel } = await this.resolveModels();
|
|
118
|
-
return serializeSearchConfiguration(configurationModel.config) + '\n' + resultsModel.getValue();
|
|
119
|
-
}
|
|
120
|
-
registerConfigChangeListeners(model) {
|
|
121
|
-
this.configChangeListenerDisposable?.dispose();
|
|
122
|
-
if (!this.isDisposed()) {
|
|
123
|
-
this.configChangeListenerDisposable = model.onConfigDidUpdate(() => {
|
|
124
|
-
if (this.lastLabel !== this.getName()) {
|
|
125
|
-
this._onDidChangeLabel.fire();
|
|
126
|
-
this.lastLabel = this.getName();
|
|
127
|
-
}
|
|
128
|
-
this.memento.getMemento(1 , 1 ).searchConfig = model.config;
|
|
129
|
-
});
|
|
130
|
-
this._register(this.configChangeListenerDisposable);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
async resolveModels() {
|
|
134
|
-
return this.model.resolve().then(data => {
|
|
135
|
-
this._cachedResultsModel = data.resultsModel;
|
|
136
|
-
this._cachedConfigurationModel = data.configurationModel;
|
|
137
|
-
if (this.lastLabel !== this.getName()) {
|
|
138
|
-
this._onDidChangeLabel.fire();
|
|
139
|
-
this.lastLabel = this.getName();
|
|
140
|
-
}
|
|
141
|
-
this.registerConfigChangeListeners(data.configurationModel);
|
|
142
|
-
return data;
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
async saveAs(group, options) {
|
|
146
|
-
const path = await this.fileDialogService.pickFileToSave(await this.suggestFileName(), options?.availableFileSystems);
|
|
147
|
-
if (path) {
|
|
148
|
-
this.telemetryService.publicLog2('searchEditor/saveSearchResults');
|
|
149
|
-
const toWrite = await this.serializeForDisk();
|
|
150
|
-
if (await this.textFileService.create([{ resource: path, value: toWrite, options: { overwrite: true } }])) {
|
|
151
|
-
this.setDirty(false);
|
|
152
|
-
if (!isEqual(path, this.modelUri)) {
|
|
153
|
-
const input = this.instantiationService.invokeFunction(getOrMakeSearchEditorInput, { fileUri: path, from: 'existingFile' });
|
|
154
|
-
input.setMatchRanges(this.getMatchRanges());
|
|
155
|
-
return input;
|
|
156
|
-
}
|
|
157
|
-
return this;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
return undefined;
|
|
161
|
-
}
|
|
162
|
-
getName(maxLength = 12) {
|
|
163
|
-
const trimToMax = (label) => (label.length < maxLength ? label : `${label.slice(0, maxLength - 3)}...`);
|
|
164
|
-
if (this.backingUri) {
|
|
165
|
-
const originalURI = EditorResourceAccessor.getOriginalUri(this);
|
|
166
|
-
return ( localizeWithPath(
|
|
167
|
-
'vs/workbench/contrib/searchEditor/browser/searchEditorInput',
|
|
168
|
-
'searchTitle.withQuery',
|
|
169
|
-
"Search: {0}",
|
|
170
|
-
basename((originalURI ?? this.backingUri).path, SEARCH_EDITOR_EXT)
|
|
171
|
-
));
|
|
172
|
-
}
|
|
173
|
-
const query = this._cachedConfigurationModel?.config?.query?.trim();
|
|
174
|
-
if (query) {
|
|
175
|
-
return ( localizeWithPath(
|
|
176
|
-
'vs/workbench/contrib/searchEditor/browser/searchEditorInput',
|
|
177
|
-
'searchTitle.withQuery',
|
|
178
|
-
"Search: {0}",
|
|
179
|
-
trimToMax(query)
|
|
180
|
-
));
|
|
181
|
-
}
|
|
182
|
-
return ( localizeWithPath(
|
|
183
|
-
'vs/workbench/contrib/searchEditor/browser/searchEditorInput',
|
|
184
|
-
'searchTitle',
|
|
185
|
-
"Search"
|
|
186
|
-
));
|
|
187
|
-
}
|
|
188
|
-
setDirty(dirty) {
|
|
189
|
-
const wasDirty = this.dirty;
|
|
190
|
-
this.dirty = dirty;
|
|
191
|
-
if (wasDirty !== dirty) {
|
|
192
|
-
this._onDidChangeDirty.fire();
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
isDirty() {
|
|
196
|
-
return this.dirty;
|
|
197
|
-
}
|
|
198
|
-
async rename(group, target) {
|
|
199
|
-
if (extname(target) === SEARCH_EDITOR_EXT) {
|
|
200
|
-
return {
|
|
201
|
-
editor: this.instantiationService.invokeFunction(getOrMakeSearchEditorInput, { from: 'existingFile', fileUri: target })
|
|
202
|
-
};
|
|
203
|
-
}
|
|
204
|
-
return undefined;
|
|
205
|
-
}
|
|
206
|
-
dispose() {
|
|
207
|
-
this.modelService.destroyModel(this.modelUri);
|
|
208
|
-
super.dispose();
|
|
209
|
-
}
|
|
210
|
-
matches(other) {
|
|
211
|
-
if (super.matches(other)) {
|
|
212
|
-
return true;
|
|
213
|
-
}
|
|
214
|
-
if (other instanceof SearchEditorInput_1) {
|
|
215
|
-
return !!(other.modelUri.fragment && other.modelUri.fragment === this.modelUri.fragment) || !!(other.backingUri && isEqual(other.backingUri, this.backingUri));
|
|
216
|
-
}
|
|
217
|
-
return false;
|
|
218
|
-
}
|
|
219
|
-
getMatchRanges() {
|
|
220
|
-
return ( (this._cachedResultsModel?.getAllDecorations() ?? [])
|
|
221
|
-
.filter(decoration => decoration.options.className === SearchEditorFindMatchClass)
|
|
222
|
-
.filter(({ range }) => !(range.startColumn === 1 && range.endColumn === 1))
|
|
223
|
-
.map(({ range }) => range));
|
|
224
|
-
}
|
|
225
|
-
async setMatchRanges(ranges) {
|
|
226
|
-
this.oldDecorationsIDs = (await this.resolveModels()).resultsModel.deltaDecorations(this.oldDecorationsIDs, ( ranges.map(
|
|
227
|
-
range => ({ range, options: { description: 'search-editor-find-match', className: SearchEditorFindMatchClass, stickiness: 1 } })
|
|
228
|
-
)));
|
|
229
|
-
}
|
|
230
|
-
async revert(group, options) {
|
|
231
|
-
if (options?.soft) {
|
|
232
|
-
this.setDirty(false);
|
|
233
|
-
return;
|
|
234
|
-
}
|
|
235
|
-
if (this.backingUri) {
|
|
236
|
-
const { config, text } = await this.instantiationService.invokeFunction(parseSavedSearchEditor, this.backingUri);
|
|
237
|
-
const { resultsModel, configurationModel } = await this.resolveModels();
|
|
238
|
-
resultsModel.setValue(text);
|
|
239
|
-
configurationModel.updateConfig(config);
|
|
240
|
-
}
|
|
241
|
-
else {
|
|
242
|
-
(await this.resolveModels()).resultsModel.setValue('');
|
|
243
|
-
}
|
|
244
|
-
super.revert(group, options);
|
|
245
|
-
this.setDirty(false);
|
|
246
|
-
}
|
|
247
|
-
async backup(token) {
|
|
248
|
-
const contents = await this.serializeForDisk();
|
|
249
|
-
if (token.isCancellationRequested) {
|
|
250
|
-
return {};
|
|
251
|
-
}
|
|
252
|
-
return {
|
|
253
|
-
content: bufferToReadable(VSBuffer.fromString(contents))
|
|
254
|
-
};
|
|
255
|
-
}
|
|
256
|
-
async suggestFileName() {
|
|
257
|
-
const query = (await this.resolveModels()).configurationModel.config.query;
|
|
258
|
-
const searchFileName = (query.replace(/[^\w \-_]+/g, '_') || 'Search') + SEARCH_EDITOR_EXT;
|
|
259
|
-
return joinPath(await this.fileDialogService.defaultFilePath(this.pathService.defaultUriScheme), searchFileName);
|
|
260
|
-
}
|
|
261
|
-
toUntyped() {
|
|
262
|
-
if (this.hasCapability(4 )) {
|
|
263
|
-
return undefined;
|
|
264
|
-
}
|
|
265
|
-
return {
|
|
266
|
-
resource: this.resource,
|
|
267
|
-
options: {
|
|
268
|
-
override: SearchEditorInput_1.ID
|
|
269
|
-
}
|
|
270
|
-
};
|
|
271
|
-
}
|
|
272
|
-
};
|
|
273
|
-
SearchEditorInput = SearchEditorInput_1 = ( __decorate([
|
|
274
|
-
( __param(2, IModelService)),
|
|
275
|
-
( __param(3, ITextFileService)),
|
|
276
|
-
( __param(4, IFileDialogService)),
|
|
277
|
-
( __param(5, IInstantiationService)),
|
|
278
|
-
( __param(6, IWorkingCopyService)),
|
|
279
|
-
( __param(7, ITelemetryService)),
|
|
280
|
-
( __param(8, IPathService)),
|
|
281
|
-
( __param(9, IStorageService))
|
|
282
|
-
], SearchEditorInput));
|
|
283
|
-
const getOrMakeSearchEditorInput = (accessor, existingData) => {
|
|
284
|
-
const storageService = accessor.get(IStorageService);
|
|
285
|
-
const configurationService = accessor.get(IConfigurationService);
|
|
286
|
-
const instantiationService = accessor.get(IInstantiationService);
|
|
287
|
-
const modelUri = existingData.from === 'model' ? existingData.modelUri : ( URI.from({ scheme: SearchEditorScheme, fragment: `${Math.random()}` }));
|
|
288
|
-
if (!( searchEditorModelFactory.models.has(modelUri))) {
|
|
289
|
-
if (existingData.from === 'existingFile') {
|
|
290
|
-
instantiationService.invokeFunction(accessor => searchEditorModelFactory.initializeModelFromExistingFile(accessor, modelUri, existingData.fileUri));
|
|
291
|
-
}
|
|
292
|
-
else {
|
|
293
|
-
const searchEditorSettings = configurationService.getValue('search').searchEditor;
|
|
294
|
-
const reuseOldSettings = searchEditorSettings.reusePriorSearchConfiguration;
|
|
295
|
-
const defaultNumberOfContextLines = searchEditorSettings.defaultNumberOfContextLines;
|
|
296
|
-
const priorConfig = reuseOldSettings ? ( new Memento(SearchEditorInput.ID, storageService)).getMemento(1 , 1 ).searchConfig : {};
|
|
297
|
-
const defaultConfig = defaultSearchConfig();
|
|
298
|
-
const config = { ...defaultConfig, ...priorConfig, ...existingData.config };
|
|
299
|
-
if (defaultNumberOfContextLines !== null && defaultNumberOfContextLines !== undefined) {
|
|
300
|
-
config.contextLines = existingData?.config?.contextLines ?? defaultNumberOfContextLines;
|
|
301
|
-
}
|
|
302
|
-
if (existingData.from === 'rawData') {
|
|
303
|
-
if (existingData.resultsContents) {
|
|
304
|
-
config.contextLines = 0;
|
|
305
|
-
}
|
|
306
|
-
instantiationService.invokeFunction(accessor => searchEditorModelFactory.initializeModelFromRawData(accessor, modelUri, config, existingData.resultsContents));
|
|
307
|
-
}
|
|
308
|
-
else {
|
|
309
|
-
instantiationService.invokeFunction(accessor => searchEditorModelFactory.initializeModelFromExistingModel(accessor, modelUri, config));
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
return instantiationService.createInstance(SearchEditorInput, modelUri, existingData.from === 'existingFile'
|
|
314
|
-
? existingData.fileUri
|
|
315
|
-
: existingData.from === 'model'
|
|
316
|
-
? existingData.backupOf
|
|
317
|
-
: undefined);
|
|
318
|
-
};
|
|
319
|
-
|
|
320
|
-
export { SEARCH_EDITOR_EXT, SearchEditorInput, getOrMakeSearchEditorInput };
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import { IModelService } from 'vscode/vscode/vs/editor/common/services/model';
|
|
2
|
-
import { ILanguageService } from 'vscode/vscode/vs/editor/common/languages/language';
|
|
3
|
-
import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
4
|
-
import { parseSavedSearchEditor, parseSerializedSearchEditor } from './searchEditorSerialization.js';
|
|
5
|
-
import { IWorkingCopyBackupService } from 'vscode/vscode/vs/workbench/services/workingCopy/common/workingCopyBackup';
|
|
6
|
-
import { assertIsDefined } from 'vscode/vscode/vs/base/common/types';
|
|
7
|
-
import { createTextBufferFactoryFromStream } from 'vscode/vscode/vs/editor/common/model/textModel';
|
|
8
|
-
import { SearchEditorWorkingCopyTypeId } from 'vscode/vscode/vs/workbench/contrib/searchEditor/browser/constants';
|
|
9
|
-
import { Emitter } from 'vscode/vscode/vs/base/common/event';
|
|
10
|
-
import { ResourceMap } from 'vscode/vscode/vs/base/common/map';
|
|
11
|
-
import { SEARCH_RESULT_LANGUAGE_ID } from 'vscode/vscode/vs/workbench/services/search/common/search';
|
|
12
|
-
|
|
13
|
-
class SearchConfigurationModel {
|
|
14
|
-
constructor(config) {
|
|
15
|
-
this.config = config;
|
|
16
|
-
this._onConfigDidUpdate = ( new Emitter());
|
|
17
|
-
this.onConfigDidUpdate = this._onConfigDidUpdate.event;
|
|
18
|
-
}
|
|
19
|
-
updateConfig(config) { this.config = config; this._onConfigDidUpdate.fire(config); }
|
|
20
|
-
}
|
|
21
|
-
class SearchEditorModel {
|
|
22
|
-
constructor(resource) {
|
|
23
|
-
this.resource = resource;
|
|
24
|
-
}
|
|
25
|
-
async resolve() {
|
|
26
|
-
return assertIsDefined(searchEditorModelFactory.models.get(this.resource)).resolve();
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
class SearchEditorModelFactory {
|
|
30
|
-
constructor() {
|
|
31
|
-
this.models = ( new ResourceMap());
|
|
32
|
-
}
|
|
33
|
-
initializeModelFromExistingModel(accessor, resource, config) {
|
|
34
|
-
if (( this.models.has(resource))) {
|
|
35
|
-
throw Error('Unable to contruct model for resource that already exists');
|
|
36
|
-
}
|
|
37
|
-
const languageService = accessor.get(ILanguageService);
|
|
38
|
-
const modelService = accessor.get(IModelService);
|
|
39
|
-
const instantiationService = accessor.get(IInstantiationService);
|
|
40
|
-
const workingCopyBackupService = accessor.get(IWorkingCopyBackupService);
|
|
41
|
-
let ongoingResolve;
|
|
42
|
-
this.models.set(resource, {
|
|
43
|
-
resolve: () => {
|
|
44
|
-
if (!ongoingResolve) {
|
|
45
|
-
ongoingResolve = (async () => {
|
|
46
|
-
const backup = await this.tryFetchModelFromBackupService(resource, languageService, modelService, workingCopyBackupService, instantiationService);
|
|
47
|
-
if (backup) {
|
|
48
|
-
return backup;
|
|
49
|
-
}
|
|
50
|
-
return Promise.resolve({
|
|
51
|
-
resultsModel: modelService.getModel(resource) ?? modelService.createModel('', languageService.createById(SEARCH_RESULT_LANGUAGE_ID), resource),
|
|
52
|
-
configurationModel: ( new SearchConfigurationModel(config))
|
|
53
|
-
});
|
|
54
|
-
})();
|
|
55
|
-
}
|
|
56
|
-
return ongoingResolve;
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
initializeModelFromRawData(accessor, resource, config, contents) {
|
|
61
|
-
if (( this.models.has(resource))) {
|
|
62
|
-
throw Error('Unable to contruct model for resource that already exists');
|
|
63
|
-
}
|
|
64
|
-
const languageService = accessor.get(ILanguageService);
|
|
65
|
-
const modelService = accessor.get(IModelService);
|
|
66
|
-
const instantiationService = accessor.get(IInstantiationService);
|
|
67
|
-
const workingCopyBackupService = accessor.get(IWorkingCopyBackupService);
|
|
68
|
-
let ongoingResolve;
|
|
69
|
-
this.models.set(resource, {
|
|
70
|
-
resolve: () => {
|
|
71
|
-
if (!ongoingResolve) {
|
|
72
|
-
ongoingResolve = (async () => {
|
|
73
|
-
const backup = await this.tryFetchModelFromBackupService(resource, languageService, modelService, workingCopyBackupService, instantiationService);
|
|
74
|
-
if (backup) {
|
|
75
|
-
return backup;
|
|
76
|
-
}
|
|
77
|
-
return Promise.resolve({
|
|
78
|
-
resultsModel: modelService.createModel(contents ?? '', languageService.createById(SEARCH_RESULT_LANGUAGE_ID), resource),
|
|
79
|
-
configurationModel: ( new SearchConfigurationModel(config))
|
|
80
|
-
});
|
|
81
|
-
})();
|
|
82
|
-
}
|
|
83
|
-
return ongoingResolve;
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
initializeModelFromExistingFile(accessor, resource, existingFile) {
|
|
88
|
-
if (( this.models.has(resource))) {
|
|
89
|
-
throw Error('Unable to contruct model for resource that already exists');
|
|
90
|
-
}
|
|
91
|
-
const languageService = accessor.get(ILanguageService);
|
|
92
|
-
const modelService = accessor.get(IModelService);
|
|
93
|
-
const instantiationService = accessor.get(IInstantiationService);
|
|
94
|
-
const workingCopyBackupService = accessor.get(IWorkingCopyBackupService);
|
|
95
|
-
let ongoingResolve;
|
|
96
|
-
this.models.set(resource, {
|
|
97
|
-
resolve: async () => {
|
|
98
|
-
if (!ongoingResolve) {
|
|
99
|
-
ongoingResolve = (async () => {
|
|
100
|
-
const backup = await this.tryFetchModelFromBackupService(resource, languageService, modelService, workingCopyBackupService, instantiationService);
|
|
101
|
-
if (backup) {
|
|
102
|
-
return backup;
|
|
103
|
-
}
|
|
104
|
-
const { text, config } = await instantiationService.invokeFunction(parseSavedSearchEditor, existingFile);
|
|
105
|
-
return ({
|
|
106
|
-
resultsModel: modelService.createModel(text ?? '', languageService.createById(SEARCH_RESULT_LANGUAGE_ID), resource),
|
|
107
|
-
configurationModel: ( new SearchConfigurationModel(config))
|
|
108
|
-
});
|
|
109
|
-
})();
|
|
110
|
-
}
|
|
111
|
-
return ongoingResolve;
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
async tryFetchModelFromBackupService(resource, languageService, modelService, workingCopyBackupService, instantiationService) {
|
|
116
|
-
const backup = await workingCopyBackupService.resolve({ resource, typeId: SearchEditorWorkingCopyTypeId });
|
|
117
|
-
let model = modelService.getModel(resource);
|
|
118
|
-
if (!model && backup) {
|
|
119
|
-
const factory = await createTextBufferFactoryFromStream(backup.value);
|
|
120
|
-
model = modelService.createModel(factory, languageService.createById(SEARCH_RESULT_LANGUAGE_ID), resource);
|
|
121
|
-
}
|
|
122
|
-
if (model) {
|
|
123
|
-
const existingFile = model.getValue();
|
|
124
|
-
const { text, config } = parseSerializedSearchEditor(existingFile);
|
|
125
|
-
modelService.destroyModel(resource);
|
|
126
|
-
return ({
|
|
127
|
-
resultsModel: modelService.createModel(text ?? '', languageService.createById(SEARCH_RESULT_LANGUAGE_ID), resource),
|
|
128
|
-
configurationModel: ( new SearchConfigurationModel(config))
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
else {
|
|
132
|
-
return undefined;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
const searchEditorModelFactory = ( new SearchEditorModelFactory());
|
|
137
|
-
|
|
138
|
-
export { SearchConfigurationModel, SearchEditorModel, searchEditorModelFactory };
|