@codingame/monaco-vscode-notebook-service-override 1.85.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/external/rollup-plugin-styles/dist/runtime/inject-css.js +3 -0
- package/external/tslib/tslib.es6.js +11 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/notebook.d.ts +5 -0
- package/notebook.js +44 -0
- package/override/vs/platform/dialogs/common/dialogs.js +8 -0
- package/package.json +32 -0
- package/vscode/src/vs/workbench/contrib/codeEditor/browser/emptyTextEditorHint/emptyTextEditorHint.css.js +6 -0
- package/vscode/src/vs/workbench/contrib/codeEditor/browser/emptyTextEditorHint/emptyTextEditorHint.js +387 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellCommands/cellCommands.js +668 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/contributedStatusBarItemController.js +109 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/executionStatusBarItemController.js +319 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/notebookVisibleCellObserver.js +58 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/statusBarProviders.js +173 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/clipboard/notebookClipboard.js +485 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/debug/notebookBreakpoints.js +106 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/debug/notebookCellPausing.js +67 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/debug/notebookDebugDecorations.js +165 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/editorHint/emptyCellEditorHint.js +67 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/editorStatusBar/editorStatusBar.js +238 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/execute/executionEditorProgress.js +72 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/media/notebookFind.css.js +6 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/notebookFind.js +168 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/notebookFindWidget.js +317 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/format/formatting.js +209 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/gettingStarted/notebookGettingStarted.js +87 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/kernelDetection/notebookKernelDetection.js +82 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/layout/layoutActions.js +67 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/marker/markerProvider.js +93 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/navigation/arrow.js +383 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariables.js +51 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariablesTree.js +46 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariablesView.js +135 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/outline/notebookOutline.js +383 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/profile/notebookProfile.js +117 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/saveParticipants/saveParticipants.js +511 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/troubleshoot/layout.js +168 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/undoRedo/notebookUndoRedo.js +57 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/viewportWarmup/viewportWarmup.js +94 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/apiActions.js +51 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/executeActions.js +702 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/layoutActions.js +268 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffCellEditorOptions.js +45 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffComponents.js +1297 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffElementOutputs.js +284 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffElementViewModel.js +563 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffNestedCellViewModel.js +108 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/eventDispatcher.js +39 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiff.css.js +6 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffActions.js +313 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffEditor.js +872 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffEditorBrowser.js +13 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffList.js +393 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffOverviewRuler.js +175 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebook.contribution.js +1121 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookAccessibility.js +159 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookExtensionPoint.js +339 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookCellStatusBarServiceImpl.js +41 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookEditorServiceImpl.js +182 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookExecutionServiceImpl.js +106 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookExecutionStateServiceImpl.js +509 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKernelHistoryServiceImpl.js +133 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKernelServiceImpl.js +342 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKeymapServiceImpl.js +111 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookLoggingServiceImpl.js +28 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookRendererMessagingServiceImpl.js +65 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookServiceImpl.js +666 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookWorkerServiceImpl.js +200 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/model/cellEdit.js +80 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/model/notebookTextModel.js +1001 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookDiffEditorInput.js +103 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookEditorModelResolverServiceImpl.js +202 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookOutputRenderer.js +80 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookProvider.js +98 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/services/notebookSimpleWorker.js +217 -0
- package/vscode/src/vs/workbench/services/workingCopy/common/abstractFileWorkingCopyManager.js +89 -0
- package/vscode/src/vs/workbench/services/workingCopy/common/fileWorkingCopyManager.js +372 -0
- package/vscode/src/vs/workbench/services/workingCopy/common/storedFileWorkingCopy.js +706 -0
- package/vscode/src/vs/workbench/services/workingCopy/common/storedFileWorkingCopyManager.js +407 -0
- package/vscode/src/vs/workbench/services/workingCopy/common/untitledFileWorkingCopy.js +144 -0
- package/vscode/src/vs/workbench/services/workingCopy/common/untitledFileWorkingCopyManager.js +129 -0
- package/worker.js +1 -0
- package/workers/notebook.worker.js +9 -0
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import './media/notebookFind.css.js';
|
|
2
|
+
import { Schemas } from 'monaco-editor/esm/vs/base/common/network.js';
|
|
3
|
+
import { isEqual } from 'monaco-editor/esm/vs/base/common/resources.js';
|
|
4
|
+
import { ICodeEditorService } from 'monaco-editor/esm/vs/editor/browser/services/codeEditorService.js';
|
|
5
|
+
import { EditorContextKeys } from 'monaco-editor/esm/vs/editor/common/editorContextKeys.js';
|
|
6
|
+
import { StartFindAction, StartFindReplaceAction, getSelectionSearchString } from 'monaco-editor/esm/vs/editor/contrib/find/browser/findController.js';
|
|
7
|
+
import { localizeWithPath } from 'monaco-editor/esm/vs/nls.js';
|
|
8
|
+
import { registerAction2, Action2 } from 'monaco-editor/esm/vs/platform/actions/common/actions.js';
|
|
9
|
+
import { ContextKeyExpr } from 'monaco-editor/esm/vs/platform/contextkey/common/contextkey.js';
|
|
10
|
+
import { NotebookFindContrib } from './notebookFindWidget.js';
|
|
11
|
+
import { getNotebookEditorFromEditorPane } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/notebookBrowser';
|
|
12
|
+
import { registerNotebookContribution } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/notebookEditorExtensions';
|
|
13
|
+
import { CellUri } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookCommon';
|
|
14
|
+
import { NOTEBOOK_EDITOR_FOCUSED, KEYBINDING_CONTEXT_NOTEBOOK_FIND_WIDGET_FOCUSED, NOTEBOOK_IS_ACTIVE_EDITOR, INTERACTIVE_WINDOW_IS_ACTIVE_EDITOR } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookContextKeys';
|
|
15
|
+
import { IEditorService } from 'vscode/vscode/vs/workbench/services/editor/common/editorService';
|
|
16
|
+
|
|
17
|
+
registerNotebookContribution(NotebookFindContrib.id, NotebookFindContrib);
|
|
18
|
+
registerAction2(class extends Action2 {
|
|
19
|
+
constructor() {
|
|
20
|
+
super({
|
|
21
|
+
id: 'notebook.hideFind',
|
|
22
|
+
title: { value: ( localizeWithPath(
|
|
23
|
+
'vs/workbench/contrib/notebook/browser/contrib/find/notebookFind',
|
|
24
|
+
'notebookActions.hideFind',
|
|
25
|
+
"Hide Find in Notebook"
|
|
26
|
+
)), original: 'Hide Find in Notebook' },
|
|
27
|
+
keybinding: {
|
|
28
|
+
when: ( ContextKeyExpr.and(NOTEBOOK_EDITOR_FOCUSED, KEYBINDING_CONTEXT_NOTEBOOK_FIND_WIDGET_FOCUSED)),
|
|
29
|
+
primary: 9 ,
|
|
30
|
+
weight: 200
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
async run(accessor) {
|
|
35
|
+
const editorService = accessor.get(IEditorService);
|
|
36
|
+
const editor = getNotebookEditorFromEditorPane(editorService.activeEditorPane);
|
|
37
|
+
if (!editor) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const controller = editor.getContribution(NotebookFindContrib.id);
|
|
41
|
+
controller.hide();
|
|
42
|
+
editor.focus();
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
registerAction2(class extends Action2 {
|
|
46
|
+
constructor() {
|
|
47
|
+
super({
|
|
48
|
+
id: 'notebook.find',
|
|
49
|
+
title: { value: ( localizeWithPath(
|
|
50
|
+
'vs/workbench/contrib/notebook/browser/contrib/find/notebookFind',
|
|
51
|
+
'notebookActions.findInNotebook',
|
|
52
|
+
"Find in Notebook"
|
|
53
|
+
)), original: 'Find in Notebook' },
|
|
54
|
+
keybinding: {
|
|
55
|
+
when: ( ContextKeyExpr.and(NOTEBOOK_EDITOR_FOCUSED, ( ContextKeyExpr.or(NOTEBOOK_IS_ACTIVE_EDITOR, INTERACTIVE_WINDOW_IS_ACTIVE_EDITOR)), ( EditorContextKeys.focus.toNegated()))),
|
|
56
|
+
primary: 36 | 2048 ,
|
|
57
|
+
weight: 200
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
async run(accessor) {
|
|
62
|
+
const editorService = accessor.get(IEditorService);
|
|
63
|
+
const editor = getNotebookEditorFromEditorPane(editorService.activeEditorPane);
|
|
64
|
+
if (!editor) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
const controller = editor.getContribution(NotebookFindContrib.id);
|
|
68
|
+
controller.show();
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
function notebookContainsTextModel(uri, textModel) {
|
|
72
|
+
if (textModel.uri.scheme === Schemas.vscodeNotebookCell) {
|
|
73
|
+
const cellUri = CellUri.parse(textModel.uri);
|
|
74
|
+
if (cellUri && isEqual(cellUri.notebook, uri)) {
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
function getSearchStringOptions(editor, opts) {
|
|
81
|
+
if (opts.seedSearchStringFromSelection === 'single') {
|
|
82
|
+
const selectionSearchString = getSelectionSearchString(editor, opts.seedSearchStringFromSelection, opts.seedSearchStringFromNonEmptySelection);
|
|
83
|
+
if (selectionSearchString) {
|
|
84
|
+
return {
|
|
85
|
+
searchString: selectionSearchString,
|
|
86
|
+
selection: editor.getSelection()
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
else if (opts.seedSearchStringFromSelection === 'multiple' && !opts.updateSearchScope) {
|
|
91
|
+
const selectionSearchString = getSelectionSearchString(editor, opts.seedSearchStringFromSelection);
|
|
92
|
+
if (selectionSearchString) {
|
|
93
|
+
return {
|
|
94
|
+
searchString: selectionSearchString,
|
|
95
|
+
selection: editor.getSelection()
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return undefined;
|
|
100
|
+
}
|
|
101
|
+
StartFindAction.addImplementation(100, (accessor, codeEditor, args) => {
|
|
102
|
+
const editorService = accessor.get(IEditorService);
|
|
103
|
+
const editor = getNotebookEditorFromEditorPane(editorService.activeEditorPane);
|
|
104
|
+
if (!editor) {
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
if (!codeEditor.hasModel()) {
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
if (!editor.hasEditorFocus() && !editor.hasWebviewFocus()) {
|
|
111
|
+
const codeEditorService = accessor.get(ICodeEditorService);
|
|
112
|
+
const textEditor = codeEditorService.getFocusedCodeEditor() || codeEditorService.getActiveCodeEditor();
|
|
113
|
+
if (editor.hasModel() && textEditor && textEditor.hasModel() && notebookContainsTextModel(editor.textModel.uri, textEditor.getModel())) ;
|
|
114
|
+
else {
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
const controller = editor.getContribution(NotebookFindContrib.id);
|
|
119
|
+
const searchStringOptions = getSearchStringOptions(codeEditor, {
|
|
120
|
+
forceRevealReplace: false,
|
|
121
|
+
seedSearchStringFromSelection: codeEditor.getOption(41 ).seedSearchStringFromSelection !== 'never' ? 'single' : 'none',
|
|
122
|
+
seedSearchStringFromNonEmptySelection: codeEditor.getOption(41 ).seedSearchStringFromSelection === 'selection',
|
|
123
|
+
seedSearchStringFromGlobalClipboard: codeEditor.getOption(41 ).globalFindClipboard,
|
|
124
|
+
shouldFocus: 1 ,
|
|
125
|
+
shouldAnimate: true,
|
|
126
|
+
updateSearchScope: false,
|
|
127
|
+
loop: codeEditor.getOption(41 ).loop
|
|
128
|
+
});
|
|
129
|
+
let options = undefined;
|
|
130
|
+
const uri = codeEditor.getModel().uri;
|
|
131
|
+
const data = CellUri.parse(uri);
|
|
132
|
+
if (searchStringOptions?.selection && data) {
|
|
133
|
+
const cell = editor.getCellByHandle(data.handle);
|
|
134
|
+
if (cell) {
|
|
135
|
+
options = {
|
|
136
|
+
searchStringSeededFrom: { cell, range: searchStringOptions.selection },
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
controller.show(searchStringOptions?.searchString, options);
|
|
141
|
+
return true;
|
|
142
|
+
});
|
|
143
|
+
StartFindReplaceAction.addImplementation(100, (accessor, codeEditor, args) => {
|
|
144
|
+
const editorService = accessor.get(IEditorService);
|
|
145
|
+
const editor = getNotebookEditorFromEditorPane(editorService.activeEditorPane);
|
|
146
|
+
if (!editor) {
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
149
|
+
if (!codeEditor.hasModel()) {
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
const controller = editor.getContribution(NotebookFindContrib.id);
|
|
153
|
+
const searchStringOptions = getSearchStringOptions(codeEditor, {
|
|
154
|
+
forceRevealReplace: false,
|
|
155
|
+
seedSearchStringFromSelection: codeEditor.getOption(41 ).seedSearchStringFromSelection !== 'never' ? 'single' : 'none',
|
|
156
|
+
seedSearchStringFromNonEmptySelection: codeEditor.getOption(41 ).seedSearchStringFromSelection === 'selection',
|
|
157
|
+
seedSearchStringFromGlobalClipboard: codeEditor.getOption(41 ).globalFindClipboard,
|
|
158
|
+
shouldFocus: 1 ,
|
|
159
|
+
shouldAnimate: true,
|
|
160
|
+
updateSearchScope: false,
|
|
161
|
+
loop: codeEditor.getOption(41 ).loop
|
|
162
|
+
});
|
|
163
|
+
if (controller) {
|
|
164
|
+
controller.replace(searchStringOptions?.searchString);
|
|
165
|
+
return true;
|
|
166
|
+
}
|
|
167
|
+
return false;
|
|
168
|
+
});
|
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
import { __decorate, __param } from '../../../../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
+
import * as dom from 'monaco-editor/esm/vs/base/browser/dom.js';
|
|
3
|
+
import { alert } from 'monaco-editor/esm/vs/base/browser/ui/aria/aria.js';
|
|
4
|
+
import { Lazy } from 'monaco-editor/esm/vs/base/common/lazy.js';
|
|
5
|
+
import { Disposable } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
|
|
6
|
+
import * as strings from 'monaco-editor/esm/vs/base/common/strings.js';
|
|
7
|
+
import { MATCHES_LIMIT } from 'monaco-editor/esm/vs/editor/contrib/find/browser/findModel.js';
|
|
8
|
+
import { FindReplaceState } from 'monaco-editor/esm/vs/editor/contrib/find/browser/findState.js';
|
|
9
|
+
import { NLS_MATCHES_LOCATION, NLS_NO_RESULTS } from 'monaco-editor/esm/vs/editor/contrib/find/browser/findWidget.js';
|
|
10
|
+
import { localizeWithPath } from 'monaco-editor/esm/vs/nls.js';
|
|
11
|
+
import { IMenuService } from 'monaco-editor/esm/vs/platform/actions/common/actions.js';
|
|
12
|
+
import { IConfigurationService } from 'monaco-editor/esm/vs/platform/configuration/common/configuration.js';
|
|
13
|
+
import { IContextKeyService } from 'monaco-editor/esm/vs/platform/contextkey/common/contextkey.js';
|
|
14
|
+
import { IContextViewService, IContextMenuService } from 'monaco-editor/esm/vs/platform/contextview/browser/contextView.js';
|
|
15
|
+
import { IInstantiationService } from 'monaco-editor/esm/vs/platform/instantiation/common/instantiation.js';
|
|
16
|
+
import { FindModel } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/contrib/find/findModel';
|
|
17
|
+
import { SimpleFindReplaceWidget } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/contrib/find/notebookFindReplaceWidget';
|
|
18
|
+
import { CellEditState } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/notebookBrowser';
|
|
19
|
+
import { KEYBINDING_CONTEXT_NOTEBOOK_FIND_WIDGET_FOCUSED } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookContextKeys';
|
|
20
|
+
|
|
21
|
+
const FIND_HIDE_TRANSITION = 'find-hide-transition';
|
|
22
|
+
const FIND_SHOW_TRANSITION = 'find-show-transition';
|
|
23
|
+
let MAX_MATCHES_COUNT_WIDTH = 69;
|
|
24
|
+
const PROGRESS_BAR_DELAY = 200;
|
|
25
|
+
let NotebookFindContrib = class NotebookFindContrib extends Disposable {
|
|
26
|
+
static { this.id = 'workbench.notebook.find'; }
|
|
27
|
+
constructor(notebookEditor, instantiationService) {
|
|
28
|
+
super();
|
|
29
|
+
this.notebookEditor = notebookEditor;
|
|
30
|
+
this.instantiationService = instantiationService;
|
|
31
|
+
this.widget = ( new Lazy(
|
|
32
|
+
() => this._register(this.instantiationService.createInstance(NotebookFindWidget, this.notebookEditor))
|
|
33
|
+
));
|
|
34
|
+
}
|
|
35
|
+
show(initialInput, options) {
|
|
36
|
+
return this.widget.value.show(initialInput, options);
|
|
37
|
+
}
|
|
38
|
+
hide() {
|
|
39
|
+
this.widget.rawValue?.hide();
|
|
40
|
+
}
|
|
41
|
+
replace(searchString) {
|
|
42
|
+
return this.widget.value.replace(searchString);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
NotebookFindContrib = ( __decorate([
|
|
46
|
+
( __param(1, IInstantiationService))
|
|
47
|
+
], NotebookFindContrib));
|
|
48
|
+
let NotebookFindWidget = class NotebookFindWidget extends SimpleFindReplaceWidget {
|
|
49
|
+
constructor(_notebookEditor, contextViewService, contextKeyService, configurationService, contextMenuService, menuService, instantiationService) {
|
|
50
|
+
super(contextViewService, contextKeyService, configurationService, contextMenuService, instantiationService, ( new FindReplaceState()), _notebookEditor);
|
|
51
|
+
this._showTimeout = null;
|
|
52
|
+
this._hideTimeout = null;
|
|
53
|
+
this._findModel = ( new FindModel(this._notebookEditor, this._state, this._configurationService));
|
|
54
|
+
dom.append(this._notebookEditor.getDomNode(), this.getDomNode());
|
|
55
|
+
this._findWidgetFocused = KEYBINDING_CONTEXT_NOTEBOOK_FIND_WIDGET_FOCUSED.bindTo(contextKeyService);
|
|
56
|
+
this._register(this._findInput.onKeyDown((e) => this._onFindInputKeyDown(e)));
|
|
57
|
+
this._register(this._replaceInput.onKeyDown((e) => this._onReplaceInputKeyDown(e)));
|
|
58
|
+
this._register(this._state.onFindReplaceStateChange((e) => {
|
|
59
|
+
this.onInputChanged();
|
|
60
|
+
if (e.isSearching) {
|
|
61
|
+
if (this._state.isSearching) {
|
|
62
|
+
this._progressBar.infinite().show(PROGRESS_BAR_DELAY);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
this._progressBar.stop().hide();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (this._findModel.currentMatch >= 0) {
|
|
69
|
+
const currentMatch = this._findModel.getCurrentMatch();
|
|
70
|
+
this._replaceBtn.setEnabled(currentMatch.isModelMatch);
|
|
71
|
+
}
|
|
72
|
+
const matches = this._findModel.findMatches;
|
|
73
|
+
this._replaceAllBtn.setEnabled(matches.length > 0 && matches.find(match => match.webviewMatches.length > 0) === undefined);
|
|
74
|
+
if (e.filters) {
|
|
75
|
+
this._findInput.updateFilterState(this._state.filters?.isModified() ?? false);
|
|
76
|
+
}
|
|
77
|
+
}));
|
|
78
|
+
this._register(dom.addDisposableListener(this.getDomNode(), dom.EventType.FOCUS, e => {
|
|
79
|
+
this._previousFocusElement = e.relatedTarget instanceof HTMLElement ? e.relatedTarget : undefined;
|
|
80
|
+
}, true));
|
|
81
|
+
}
|
|
82
|
+
_onFindInputKeyDown(e) {
|
|
83
|
+
if (e.equals(3 )) {
|
|
84
|
+
this.find(false);
|
|
85
|
+
e.preventDefault();
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
else if (e.equals(1024 | 3 )) {
|
|
89
|
+
this.find(true);
|
|
90
|
+
e.preventDefault();
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
_onReplaceInputKeyDown(e) {
|
|
95
|
+
if (e.equals(3 )) {
|
|
96
|
+
this.replaceOne();
|
|
97
|
+
e.preventDefault();
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
onInputChanged() {
|
|
102
|
+
this._state.change({ searchString: this.inputValue }, false);
|
|
103
|
+
const findMatches = this._findModel.findMatches;
|
|
104
|
+
if (findMatches && findMatches.length) {
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
findIndex(index) {
|
|
110
|
+
this._findModel.find({ index });
|
|
111
|
+
}
|
|
112
|
+
find(previous) {
|
|
113
|
+
this._findModel.find({ previous });
|
|
114
|
+
}
|
|
115
|
+
replaceOne() {
|
|
116
|
+
if (!this._notebookEditor.hasModel()) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
if (!this._findModel.findMatches.length) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
this._findModel.ensureFindMatches();
|
|
123
|
+
if (this._findModel.currentMatch < 0) {
|
|
124
|
+
this._findModel.find({ previous: false });
|
|
125
|
+
}
|
|
126
|
+
const currentMatch = this._findModel.getCurrentMatch();
|
|
127
|
+
const cell = currentMatch.cell;
|
|
128
|
+
if (currentMatch.isModelMatch) {
|
|
129
|
+
const match = currentMatch.match;
|
|
130
|
+
this._progressBar.infinite().show(PROGRESS_BAR_DELAY);
|
|
131
|
+
const replacePattern = this.replacePattern;
|
|
132
|
+
const replaceString = replacePattern.buildReplaceString(match.matches, this._state.preserveCase);
|
|
133
|
+
const viewModel = this._notebookEditor.getViewModel();
|
|
134
|
+
viewModel.replaceOne(cell, match.range, replaceString).then(() => {
|
|
135
|
+
this._progressBar.stop();
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
console.error('Replace does not work for output match');
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
replaceAll() {
|
|
143
|
+
if (!this._notebookEditor.hasModel()) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
this._progressBar.infinite().show(PROGRESS_BAR_DELAY);
|
|
147
|
+
const replacePattern = this.replacePattern;
|
|
148
|
+
const cellFindMatches = this._findModel.findMatches;
|
|
149
|
+
const replaceStrings = [];
|
|
150
|
+
cellFindMatches.forEach(cellFindMatch => {
|
|
151
|
+
cellFindMatch.contentMatches.forEach(match => {
|
|
152
|
+
const matches = match.matches;
|
|
153
|
+
replaceStrings.push(replacePattern.buildReplaceString(matches, this._state.preserveCase));
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
const viewModel = this._notebookEditor.getViewModel();
|
|
157
|
+
viewModel.replaceAll(this._findModel.findMatches, replaceStrings).then(() => {
|
|
158
|
+
this._progressBar.stop();
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
findFirst() { }
|
|
162
|
+
onFocusTrackerFocus() {
|
|
163
|
+
this._findWidgetFocused.set(true);
|
|
164
|
+
}
|
|
165
|
+
onFocusTrackerBlur() {
|
|
166
|
+
this._previousFocusElement = undefined;
|
|
167
|
+
this._findWidgetFocused.reset();
|
|
168
|
+
}
|
|
169
|
+
onReplaceInputFocusTrackerFocus() {
|
|
170
|
+
}
|
|
171
|
+
onReplaceInputFocusTrackerBlur() {
|
|
172
|
+
}
|
|
173
|
+
onFindInputFocusTrackerFocus() { }
|
|
174
|
+
onFindInputFocusTrackerBlur() { }
|
|
175
|
+
async show(initialInput, options) {
|
|
176
|
+
const searchStringUpdate = this._state.searchString !== initialInput;
|
|
177
|
+
super.show(initialInput, options);
|
|
178
|
+
this._state.change({ searchString: initialInput ?? this._state.searchString, isRevealed: true }, false);
|
|
179
|
+
if (typeof options?.matchIndex === 'number') {
|
|
180
|
+
if (!this._findModel.findMatches.length) {
|
|
181
|
+
await this._findModel.research();
|
|
182
|
+
}
|
|
183
|
+
this.findIndex(options.matchIndex);
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
this._findInput.select();
|
|
187
|
+
}
|
|
188
|
+
if (!searchStringUpdate && options?.searchStringSeededFrom) {
|
|
189
|
+
this._findModel.refreshCurrentMatch(options.searchStringSeededFrom);
|
|
190
|
+
}
|
|
191
|
+
if (this._showTimeout === null) {
|
|
192
|
+
if (this._hideTimeout !== null) {
|
|
193
|
+
dom.getWindow(this.getDomNode()).clearTimeout(this._hideTimeout);
|
|
194
|
+
this._hideTimeout = null;
|
|
195
|
+
this._notebookEditor.removeClassName(FIND_HIDE_TRANSITION);
|
|
196
|
+
}
|
|
197
|
+
this._notebookEditor.addClassName(FIND_SHOW_TRANSITION);
|
|
198
|
+
this._showTimeout = dom.getWindow(this.getDomNode()).setTimeout(() => {
|
|
199
|
+
this._notebookEditor.removeClassName(FIND_SHOW_TRANSITION);
|
|
200
|
+
this._showTimeout = null;
|
|
201
|
+
}, 200);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
replace(initialFindInput, initialReplaceInput) {
|
|
205
|
+
super.showWithReplace(initialFindInput, initialReplaceInput);
|
|
206
|
+
this._state.change({ searchString: initialFindInput ?? '', replaceString: initialReplaceInput ?? '', isRevealed: true }, false);
|
|
207
|
+
this._replaceInput.select();
|
|
208
|
+
if (this._showTimeout === null) {
|
|
209
|
+
if (this._hideTimeout !== null) {
|
|
210
|
+
dom.getWindow(this.getDomNode()).clearTimeout(this._hideTimeout);
|
|
211
|
+
this._hideTimeout = null;
|
|
212
|
+
this._notebookEditor.removeClassName(FIND_HIDE_TRANSITION);
|
|
213
|
+
}
|
|
214
|
+
this._notebookEditor.addClassName(FIND_SHOW_TRANSITION);
|
|
215
|
+
this._showTimeout = dom.getWindow(this.getDomNode()).setTimeout(() => {
|
|
216
|
+
this._notebookEditor.removeClassName(FIND_SHOW_TRANSITION);
|
|
217
|
+
this._showTimeout = null;
|
|
218
|
+
}, 200);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
hide() {
|
|
222
|
+
super.hide();
|
|
223
|
+
this._state.change({ isRevealed: false }, false);
|
|
224
|
+
this._findModel.clear();
|
|
225
|
+
this._notebookEditor.findStop();
|
|
226
|
+
this._progressBar.stop();
|
|
227
|
+
if (this._hideTimeout === null) {
|
|
228
|
+
if (this._showTimeout !== null) {
|
|
229
|
+
dom.getWindow(this.getDomNode()).clearTimeout(this._showTimeout);
|
|
230
|
+
this._showTimeout = null;
|
|
231
|
+
this._notebookEditor.removeClassName(FIND_SHOW_TRANSITION);
|
|
232
|
+
}
|
|
233
|
+
this._notebookEditor.addClassName(FIND_HIDE_TRANSITION);
|
|
234
|
+
this._hideTimeout = dom.getWindow(this.getDomNode()).setTimeout(() => {
|
|
235
|
+
this._notebookEditor.removeClassName(FIND_HIDE_TRANSITION);
|
|
236
|
+
}, 200);
|
|
237
|
+
}
|
|
238
|
+
if (this._previousFocusElement && this._previousFocusElement.offsetParent) {
|
|
239
|
+
this._previousFocusElement.focus();
|
|
240
|
+
this._previousFocusElement = undefined;
|
|
241
|
+
}
|
|
242
|
+
if (this._notebookEditor.hasModel()) {
|
|
243
|
+
for (let i = 0; i < this._notebookEditor.getLength(); i++) {
|
|
244
|
+
const cell = this._notebookEditor.cellAt(i);
|
|
245
|
+
if (cell.getEditState() === CellEditState.Editing && cell.editStateSource === 'find') {
|
|
246
|
+
cell.updateEditState(CellEditState.Preview, 'closeFind');
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
_updateMatchesCount() {
|
|
252
|
+
if (!this._findModel || !this._findModel.findMatches) {
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
this._matchesCount.style.width = MAX_MATCHES_COUNT_WIDTH + 'px';
|
|
256
|
+
this._matchesCount.title = '';
|
|
257
|
+
if (this._matchesCount.firstChild) {
|
|
258
|
+
this._matchesCount.removeChild(this._matchesCount.firstChild);
|
|
259
|
+
}
|
|
260
|
+
let label;
|
|
261
|
+
if (this._state.matchesCount > 0) {
|
|
262
|
+
let matchesCount = String(this._state.matchesCount);
|
|
263
|
+
if (this._state.matchesCount >= MATCHES_LIMIT) {
|
|
264
|
+
matchesCount += '+';
|
|
265
|
+
}
|
|
266
|
+
const matchesPosition = this._findModel.currentMatch < 0 ? '?' : String((this._findModel.currentMatch + 1));
|
|
267
|
+
label = strings.format(NLS_MATCHES_LOCATION, matchesPosition, matchesCount);
|
|
268
|
+
}
|
|
269
|
+
else {
|
|
270
|
+
label = NLS_NO_RESULTS;
|
|
271
|
+
}
|
|
272
|
+
this._matchesCount.appendChild(document.createTextNode(label));
|
|
273
|
+
alert(this._getAriaLabel(label, this._state.currentMatch, this._state.searchString));
|
|
274
|
+
MAX_MATCHES_COUNT_WIDTH = Math.max(MAX_MATCHES_COUNT_WIDTH, this._matchesCount.clientWidth);
|
|
275
|
+
}
|
|
276
|
+
_getAriaLabel(label, currentMatch, searchString) {
|
|
277
|
+
if (label === NLS_NO_RESULTS) {
|
|
278
|
+
return searchString === ''
|
|
279
|
+
? ( localizeWithPath(
|
|
280
|
+
'vs/workbench/contrib/notebook/browser/contrib/find/notebookFindWidget',
|
|
281
|
+
'ariaSearchNoResultEmpty',
|
|
282
|
+
"{0} found",
|
|
283
|
+
label
|
|
284
|
+
))
|
|
285
|
+
: ( localizeWithPath(
|
|
286
|
+
'vs/workbench/contrib/notebook/browser/contrib/find/notebookFindWidget',
|
|
287
|
+
'ariaSearchNoResult',
|
|
288
|
+
"{0} found for '{1}'",
|
|
289
|
+
label,
|
|
290
|
+
searchString
|
|
291
|
+
));
|
|
292
|
+
}
|
|
293
|
+
return ( localizeWithPath(
|
|
294
|
+
'vs/workbench/contrib/notebook/browser/contrib/find/notebookFindWidget',
|
|
295
|
+
'ariaSearchNoResultWithLineNumNoCurrentMatch',
|
|
296
|
+
"{0} found for '{1}'",
|
|
297
|
+
label,
|
|
298
|
+
searchString
|
|
299
|
+
));
|
|
300
|
+
}
|
|
301
|
+
dispose() {
|
|
302
|
+
this._notebookEditor?.removeClassName(FIND_SHOW_TRANSITION);
|
|
303
|
+
this._notebookEditor?.removeClassName(FIND_HIDE_TRANSITION);
|
|
304
|
+
this._findModel.dispose();
|
|
305
|
+
super.dispose();
|
|
306
|
+
}
|
|
307
|
+
};
|
|
308
|
+
NotebookFindWidget = ( __decorate([
|
|
309
|
+
( __param(1, IContextViewService)),
|
|
310
|
+
( __param(2, IContextKeyService)),
|
|
311
|
+
( __param(3, IConfigurationService)),
|
|
312
|
+
( __param(4, IContextMenuService)),
|
|
313
|
+
( __param(5, IMenuService)),
|
|
314
|
+
( __param(6, IInstantiationService))
|
|
315
|
+
], NotebookFindWidget));
|
|
316
|
+
|
|
317
|
+
export { NotebookFindContrib };
|