@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,872 @@
|
|
|
1
|
+
import { __decorate, __param } from '../../../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
+
import * as nls from 'monaco-editor/esm/vs/nls.js';
|
|
3
|
+
import * as dom from 'monaco-editor/esm/vs/base/browser/dom.js';
|
|
4
|
+
import { findLastIdx } from 'monaco-editor/esm/vs/base/common/arraysFind.js';
|
|
5
|
+
import { IStorageService } from 'monaco-editor/esm/vs/platform/storage/common/storage.js';
|
|
6
|
+
import { ITelemetryService } from 'monaco-editor/esm/vs/platform/telemetry/common/telemetry.js';
|
|
7
|
+
import { registerThemingParticipant, IThemeService } from 'monaco-editor/esm/vs/platform/theme/common/themeService.js';
|
|
8
|
+
import { getDefaultNotebookCreationOptions } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/notebookEditorWidget';
|
|
9
|
+
import { CancellationTokenSource } from 'monaco-editor/esm/vs/base/common/cancellation.js';
|
|
10
|
+
import { SideBySideDiffElementViewModel, SingleSideDiffElementViewModel } from './diffElementViewModel.js';
|
|
11
|
+
import { IInstantiationService } from 'monaco-editor/esm/vs/platform/instantiation/common/instantiation.js';
|
|
12
|
+
import { CellDiffSingleSideRenderer, CellDiffSideBySideRenderer, NotebookTextDiffList, NotebookCellTextDiffListDelegate } from './notebookDiffList.js';
|
|
13
|
+
import { IContextKeyService } from 'monaco-editor/esm/vs/platform/contextkey/common/contextkey.js';
|
|
14
|
+
import { editorBackground, foreground, focusBorder, diffDiagonalFill } from 'monaco-editor/esm/vs/platform/theme/common/colorRegistry.js';
|
|
15
|
+
import { INotebookEditorWorkerService } from 'vscode/vscode/vs/workbench/contrib/notebook/common/services/notebookWorkerService';
|
|
16
|
+
import { IConfigurationService } from 'monaco-editor/esm/vs/platform/configuration/common/configuration.js';
|
|
17
|
+
import { BareFontInfo } from 'monaco-editor/esm/vs/editor/common/config/fontInfo.js';
|
|
18
|
+
import { PixelRatio } from 'monaco-editor/esm/vs/base/browser/browser.js';
|
|
19
|
+
import { DiffSide, DIFF_CELL_MARGIN } from './notebookDiffEditorBrowser.js';
|
|
20
|
+
import { Emitter, Event } from 'monaco-editor/esm/vs/base/common/event.js';
|
|
21
|
+
import { DisposableStore, toDisposable } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
|
|
22
|
+
import { EditorPane } from 'vscode/vscode/vs/workbench/browser/parts/editor/editorPane';
|
|
23
|
+
import { NOTEBOOK_DIFF_EDITOR_ID, NotebookSetting, CellUri } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookCommon';
|
|
24
|
+
import { SequencerByKey } from 'monaco-editor/esm/vs/base/common/async.js';
|
|
25
|
+
import { generateUuid } from 'monaco-editor/esm/vs/base/common/uuid.js';
|
|
26
|
+
import { DiffNestedCellViewModel } from './diffNestedCellViewModel.js';
|
|
27
|
+
import { BackLayerWebView } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/view/renderers/backLayerWebView';
|
|
28
|
+
import { NotebookDiffEditorEventDispatcher, NotebookDiffLayoutChangedEvent } from './eventDispatcher.js';
|
|
29
|
+
import { FontMeasurements } from 'monaco-editor/esm/vs/editor/browser/config/fontMeasurements.js';
|
|
30
|
+
import { NotebookOptions } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/notebookOptions';
|
|
31
|
+
import { INotebookExecutionStateService } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookExecutionStateService';
|
|
32
|
+
import { cellRangesToIndexes, cellIndexesToRanges } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookRange';
|
|
33
|
+
import { NotebookDiffOverviewRuler } from './notebookDiffOverviewRuler.js';
|
|
34
|
+
import { registerZIndex, ZIndex } from 'vscode/vscode/vs/platform/layout/browser/zIndexRegistry';
|
|
35
|
+
|
|
36
|
+
var NotebookTextDiffEditor_1;
|
|
37
|
+
const $ = dom.$;
|
|
38
|
+
class NotebookDiffEditorSelection {
|
|
39
|
+
constructor(selections) {
|
|
40
|
+
this.selections = selections;
|
|
41
|
+
}
|
|
42
|
+
compare(other) {
|
|
43
|
+
if (!(other instanceof NotebookDiffEditorSelection)) {
|
|
44
|
+
return 3 ;
|
|
45
|
+
}
|
|
46
|
+
if (this.selections.length !== other.selections.length) {
|
|
47
|
+
return 3 ;
|
|
48
|
+
}
|
|
49
|
+
for (let i = 0; i < this.selections.length; i++) {
|
|
50
|
+
if (this.selections[i] !== other.selections[i]) {
|
|
51
|
+
return 3 ;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return 1 ;
|
|
55
|
+
}
|
|
56
|
+
restore(options) {
|
|
57
|
+
const notebookOptions = {
|
|
58
|
+
cellSelections: cellIndexesToRanges(this.selections)
|
|
59
|
+
};
|
|
60
|
+
Object.assign(notebookOptions, options);
|
|
61
|
+
return notebookOptions;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
let NotebookTextDiffEditor = class NotebookTextDiffEditor extends EditorPane {
|
|
65
|
+
static { NotebookTextDiffEditor_1 = this; }
|
|
66
|
+
static { this.ENTIRE_DIFF_OVERVIEW_WIDTH = 30; }
|
|
67
|
+
static { this.ID = NOTEBOOK_DIFF_EDITOR_ID; }
|
|
68
|
+
get textModel() {
|
|
69
|
+
return this._model?.modified.notebook;
|
|
70
|
+
}
|
|
71
|
+
get notebookOptions() {
|
|
72
|
+
return this._notebookOptions;
|
|
73
|
+
}
|
|
74
|
+
get isDisposed() {
|
|
75
|
+
return this._isDisposed;
|
|
76
|
+
}
|
|
77
|
+
constructor(instantiationService, themeService, contextKeyService, notebookEditorWorkerService, configurationService, telemetryService, storageService, notebookExecutionStateService) {
|
|
78
|
+
super(NotebookTextDiffEditor_1.ID, telemetryService, themeService, storageService);
|
|
79
|
+
this.instantiationService = instantiationService;
|
|
80
|
+
this.contextKeyService = contextKeyService;
|
|
81
|
+
this.notebookEditorWorkerService = notebookEditorWorkerService;
|
|
82
|
+
this.configurationService = configurationService;
|
|
83
|
+
this.creationOptions = getDefaultNotebookCreationOptions();
|
|
84
|
+
this._dimension = null;
|
|
85
|
+
this._diffElementViewModels = [];
|
|
86
|
+
this._modifiedWebview = null;
|
|
87
|
+
this._originalWebview = null;
|
|
88
|
+
this._webviewTransparentCover = null;
|
|
89
|
+
this._onMouseUp = this._register(( new Emitter()));
|
|
90
|
+
this.onMouseUp = this._onMouseUp.event;
|
|
91
|
+
this._onDidScroll = this._register(( new Emitter()));
|
|
92
|
+
this.onDidScroll = this._onDidScroll.event;
|
|
93
|
+
this._model = null;
|
|
94
|
+
this._modifiedResourceDisposableStore = this._register(( new DisposableStore()));
|
|
95
|
+
this._insetModifyQueueByOutputId = ( new SequencerByKey());
|
|
96
|
+
this._onDidDynamicOutputRendered = this._register(( new Emitter()));
|
|
97
|
+
this.onDidDynamicOutputRendered = this._onDidDynamicOutputRendered.event;
|
|
98
|
+
this._localStore = this._register(( new DisposableStore()));
|
|
99
|
+
this._onDidChangeSelection = this._register(( new Emitter()));
|
|
100
|
+
this.onDidChangeSelection = this._onDidChangeSelection.event;
|
|
101
|
+
this._isDisposed = false;
|
|
102
|
+
this.pendingLayouts = ( new WeakMap());
|
|
103
|
+
this._notebookOptions = ( new NotebookOptions(this.configurationService, notebookExecutionStateService, false));
|
|
104
|
+
this._register(this._notebookOptions);
|
|
105
|
+
const editorOptions = this.configurationService.getValue('editor');
|
|
106
|
+
this._fontInfo = FontMeasurements.readFontInfo(BareFontInfo.createFromRawSettings(editorOptions, PixelRatio.value));
|
|
107
|
+
this._revealFirst = true;
|
|
108
|
+
}
|
|
109
|
+
isOverviewRulerEnabled() {
|
|
110
|
+
return this.configurationService.getValue(NotebookSetting.diffOverviewRuler) ?? false;
|
|
111
|
+
}
|
|
112
|
+
getSelection() {
|
|
113
|
+
const selections = this._list.getFocus();
|
|
114
|
+
return ( new NotebookDiffEditorSelection(selections));
|
|
115
|
+
}
|
|
116
|
+
toggleNotebookCellSelection(cell) {
|
|
117
|
+
}
|
|
118
|
+
updatePerformanceMetadata(cellId, executionId, duration, rendererId) {
|
|
119
|
+
}
|
|
120
|
+
async focusNotebookCell(cell, focus) {
|
|
121
|
+
}
|
|
122
|
+
async focusNextNotebookCell(cell, focus) {
|
|
123
|
+
}
|
|
124
|
+
didFocusOutputInputChange(inputFocused) {
|
|
125
|
+
}
|
|
126
|
+
getScrollTop() {
|
|
127
|
+
return this._list?.scrollTop ?? 0;
|
|
128
|
+
}
|
|
129
|
+
getScrollHeight() {
|
|
130
|
+
return this._list?.scrollHeight ?? 0;
|
|
131
|
+
}
|
|
132
|
+
delegateVerticalScrollbarPointerDown(browserEvent) {
|
|
133
|
+
this._list?.delegateVerticalScrollbarPointerDown(browserEvent);
|
|
134
|
+
}
|
|
135
|
+
updateOutputHeight(cellInfo, output, outputHeight, isInit) {
|
|
136
|
+
const diffElement = cellInfo.diffElement;
|
|
137
|
+
const cell = this.getCellByInfo(cellInfo);
|
|
138
|
+
const outputIndex = cell.outputsViewModels.indexOf(output);
|
|
139
|
+
if (diffElement instanceof SideBySideDiffElementViewModel) {
|
|
140
|
+
const info = CellUri.parse(cellInfo.cellUri);
|
|
141
|
+
if (!info) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
diffElement.updateOutputHeight(( info.notebook.toString()) === this._model?.original.resource.toString() ? DiffSide.Original : DiffSide.Modified, outputIndex, outputHeight);
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
diffElement.updateOutputHeight(diffElement.type === 'insert' ? DiffSide.Modified : DiffSide.Original, outputIndex, outputHeight);
|
|
148
|
+
}
|
|
149
|
+
if (isInit) {
|
|
150
|
+
this._onDidDynamicOutputRendered.fire({ cell, output });
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
setMarkupCellEditState(cellId, editState) {
|
|
154
|
+
}
|
|
155
|
+
didStartDragMarkupCell(cellId, event) {
|
|
156
|
+
}
|
|
157
|
+
didDragMarkupCell(cellId, event) {
|
|
158
|
+
}
|
|
159
|
+
didEndDragMarkupCell(cellId) {
|
|
160
|
+
}
|
|
161
|
+
didDropMarkupCell(cellId) {
|
|
162
|
+
}
|
|
163
|
+
didResizeOutput(cellId) {
|
|
164
|
+
}
|
|
165
|
+
createEditor(parent) {
|
|
166
|
+
this._rootElement = dom.append(parent, dom.$('.notebook-text-diff-editor'));
|
|
167
|
+
this._overflowContainer = document.createElement('div');
|
|
168
|
+
this._overflowContainer.classList.add('notebook-overflow-widget-container', 'monaco-editor');
|
|
169
|
+
dom.append(parent, this._overflowContainer);
|
|
170
|
+
const renderers = [
|
|
171
|
+
this.instantiationService.createInstance(CellDiffSingleSideRenderer, this),
|
|
172
|
+
this.instantiationService.createInstance(CellDiffSideBySideRenderer, this),
|
|
173
|
+
];
|
|
174
|
+
this._listViewContainer = dom.append(this._rootElement, dom.$('.notebook-diff-list-view'));
|
|
175
|
+
this._list = this.instantiationService.createInstance(NotebookTextDiffList, 'NotebookTextDiff', this._listViewContainer, this.instantiationService.createInstance(NotebookCellTextDiffListDelegate), renderers, this.contextKeyService, {
|
|
176
|
+
setRowLineHeight: false,
|
|
177
|
+
setRowHeight: false,
|
|
178
|
+
supportDynamicHeights: true,
|
|
179
|
+
horizontalScrolling: false,
|
|
180
|
+
keyboardSupport: false,
|
|
181
|
+
mouseSupport: true,
|
|
182
|
+
multipleSelectionSupport: false,
|
|
183
|
+
typeNavigationEnabled: true,
|
|
184
|
+
paddingBottom: 0,
|
|
185
|
+
styleController: (_suffix) => { return this._list; },
|
|
186
|
+
overrideStyles: {
|
|
187
|
+
listBackground: editorBackground,
|
|
188
|
+
listActiveSelectionBackground: editorBackground,
|
|
189
|
+
listActiveSelectionForeground: foreground,
|
|
190
|
+
listFocusAndSelectionBackground: editorBackground,
|
|
191
|
+
listFocusAndSelectionForeground: foreground,
|
|
192
|
+
listFocusBackground: editorBackground,
|
|
193
|
+
listFocusForeground: foreground,
|
|
194
|
+
listHoverForeground: foreground,
|
|
195
|
+
listHoverBackground: editorBackground,
|
|
196
|
+
listHoverOutline: focusBorder,
|
|
197
|
+
listFocusOutline: focusBorder,
|
|
198
|
+
listInactiveSelectionBackground: editorBackground,
|
|
199
|
+
listInactiveSelectionForeground: foreground,
|
|
200
|
+
listInactiveFocusBackground: editorBackground,
|
|
201
|
+
listInactiveFocusOutline: editorBackground,
|
|
202
|
+
},
|
|
203
|
+
accessibilityProvider: {
|
|
204
|
+
getAriaLabel() { return null; },
|
|
205
|
+
getWidgetAriaLabel() {
|
|
206
|
+
return ( nls.localizeWithPath(
|
|
207
|
+
'vs/workbench/contrib/notebook/browser/diff/notebookDiffEditor',
|
|
208
|
+
'notebookTreeAriaLabel',
|
|
209
|
+
"Notebook Text Diff"
|
|
210
|
+
));
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
});
|
|
214
|
+
this._register(this._list);
|
|
215
|
+
this._register(this._list.onMouseUp(e => {
|
|
216
|
+
if (e.element) {
|
|
217
|
+
this._onMouseUp.fire({ event: e.browserEvent, target: e.element });
|
|
218
|
+
}
|
|
219
|
+
}));
|
|
220
|
+
this._register(this._list.onDidScroll(() => {
|
|
221
|
+
this._onDidScroll.fire();
|
|
222
|
+
}));
|
|
223
|
+
this._register(this._list.onDidChangeFocus(() => this._onDidChangeSelection.fire({ reason: 2 })));
|
|
224
|
+
this._overviewRulerContainer = document.createElement('div');
|
|
225
|
+
this._overviewRulerContainer.classList.add('notebook-overview-ruler-container');
|
|
226
|
+
this._rootElement.appendChild(this._overviewRulerContainer);
|
|
227
|
+
this._registerOverviewRuler();
|
|
228
|
+
this._webviewTransparentCover = dom.append(this._list.rowsContainer, $('.webview-cover'));
|
|
229
|
+
this._webviewTransparentCover.style.display = 'none';
|
|
230
|
+
this._register(dom.addStandardDisposableGenericMouseDownListener(this._overflowContainer, (e) => {
|
|
231
|
+
if (e.target.classList.contains('slider') && this._webviewTransparentCover) {
|
|
232
|
+
this._webviewTransparentCover.style.display = 'block';
|
|
233
|
+
}
|
|
234
|
+
}));
|
|
235
|
+
this._register(dom.addStandardDisposableGenericMouseUpListener(this._overflowContainer, () => {
|
|
236
|
+
if (this._webviewTransparentCover) {
|
|
237
|
+
this._webviewTransparentCover.style.display = 'none';
|
|
238
|
+
}
|
|
239
|
+
}));
|
|
240
|
+
this._register(this._list.onDidScroll(e => {
|
|
241
|
+
this._webviewTransparentCover.style.top = `${e.scrollTop}px`;
|
|
242
|
+
}));
|
|
243
|
+
}
|
|
244
|
+
_registerOverviewRuler() {
|
|
245
|
+
this._overviewRuler = this._register(this.instantiationService.createInstance(NotebookDiffOverviewRuler, this, NotebookTextDiffEditor_1.ENTIRE_DIFF_OVERVIEW_WIDTH, this._overviewRulerContainer));
|
|
246
|
+
}
|
|
247
|
+
_updateOutputsOffsetsInWebview(scrollTop, scrollHeight, activeWebview, getActiveNestedCell, diffSide) {
|
|
248
|
+
activeWebview.element.style.height = `${scrollHeight}px`;
|
|
249
|
+
if (activeWebview.insetMapping) {
|
|
250
|
+
const updateItems = [];
|
|
251
|
+
const removedItems = [];
|
|
252
|
+
activeWebview.insetMapping.forEach((value, key) => {
|
|
253
|
+
const cell = getActiveNestedCell(value.cellInfo.diffElement);
|
|
254
|
+
if (!cell) {
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
const viewIndex = this._list.indexOf(value.cellInfo.diffElement);
|
|
258
|
+
if (viewIndex === undefined) {
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
if (cell.outputsViewModels.indexOf(key) < 0) {
|
|
262
|
+
removedItems.push(key);
|
|
263
|
+
}
|
|
264
|
+
else {
|
|
265
|
+
const cellTop = this._list.getCellViewScrollTop(value.cellInfo.diffElement);
|
|
266
|
+
const outputIndex = cell.outputsViewModels.indexOf(key);
|
|
267
|
+
const outputOffset = value.cellInfo.diffElement.getOutputOffsetInCell(diffSide, outputIndex);
|
|
268
|
+
updateItems.push({
|
|
269
|
+
cell,
|
|
270
|
+
output: key,
|
|
271
|
+
cellTop: cellTop,
|
|
272
|
+
outputOffset: outputOffset,
|
|
273
|
+
forceDisplay: false
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
activeWebview.removeInsets(removedItems);
|
|
278
|
+
if (updateItems.length) {
|
|
279
|
+
activeWebview.updateScrollTops(updateItems, []);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
async setInput(input, options, context, token) {
|
|
284
|
+
await super.setInput(input, options, context, token);
|
|
285
|
+
const model = await input.resolve();
|
|
286
|
+
if (this._model !== model) {
|
|
287
|
+
this._detachModel();
|
|
288
|
+
this._model = model;
|
|
289
|
+
this._attachModel();
|
|
290
|
+
}
|
|
291
|
+
this._model = model;
|
|
292
|
+
if (this._model === null) {
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
this._revealFirst = true;
|
|
296
|
+
this._modifiedResourceDisposableStore.clear();
|
|
297
|
+
this._layoutCancellationTokenSource = ( new CancellationTokenSource());
|
|
298
|
+
this._modifiedResourceDisposableStore.add(Event.any(this._model.original.notebook.onDidChangeContent, this._model.modified.notebook.onDidChangeContent)(e => {
|
|
299
|
+
if (this._model !== null) {
|
|
300
|
+
this._layoutCancellationTokenSource?.dispose();
|
|
301
|
+
this._layoutCancellationTokenSource = ( new CancellationTokenSource());
|
|
302
|
+
this.updateLayout(this._layoutCancellationTokenSource.token);
|
|
303
|
+
}
|
|
304
|
+
}));
|
|
305
|
+
await this._createOriginalWebview(generateUuid(), this._model.original.viewType, this._model.original.resource);
|
|
306
|
+
if (this._originalWebview) {
|
|
307
|
+
this._modifiedResourceDisposableStore.add(this._originalWebview);
|
|
308
|
+
}
|
|
309
|
+
await this._createModifiedWebview(generateUuid(), this._model.modified.viewType, this._model.modified.resource);
|
|
310
|
+
if (this._modifiedWebview) {
|
|
311
|
+
this._modifiedResourceDisposableStore.add(this._modifiedWebview);
|
|
312
|
+
}
|
|
313
|
+
await this.updateLayout(this._layoutCancellationTokenSource.token, options?.cellSelections ? cellRangesToIndexes(options.cellSelections) : undefined);
|
|
314
|
+
}
|
|
315
|
+
_detachModel() {
|
|
316
|
+
this._localStore.clear();
|
|
317
|
+
this._originalWebview?.dispose();
|
|
318
|
+
this._originalWebview?.element.remove();
|
|
319
|
+
this._originalWebview = null;
|
|
320
|
+
this._modifiedWebview?.dispose();
|
|
321
|
+
this._modifiedWebview?.element.remove();
|
|
322
|
+
this._modifiedWebview = null;
|
|
323
|
+
this._modifiedResourceDisposableStore.clear();
|
|
324
|
+
this._list.clear();
|
|
325
|
+
}
|
|
326
|
+
_attachModel() {
|
|
327
|
+
this._eventDispatcher = ( new NotebookDiffEditorEventDispatcher());
|
|
328
|
+
const updateInsets = () => {
|
|
329
|
+
dom.scheduleAtNextAnimationFrame(dom.getWindow(this._listViewContainer), () => {
|
|
330
|
+
if (this._isDisposed) {
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
if (this._modifiedWebview) {
|
|
334
|
+
this._updateOutputsOffsetsInWebview(this._list.scrollTop, this._list.scrollHeight, this._modifiedWebview, (diffElement) => {
|
|
335
|
+
return diffElement.modified;
|
|
336
|
+
}, DiffSide.Modified);
|
|
337
|
+
}
|
|
338
|
+
if (this._originalWebview) {
|
|
339
|
+
this._updateOutputsOffsetsInWebview(this._list.scrollTop, this._list.scrollHeight, this._originalWebview, (diffElement) => {
|
|
340
|
+
return diffElement.original;
|
|
341
|
+
}, DiffSide.Original);
|
|
342
|
+
}
|
|
343
|
+
});
|
|
344
|
+
};
|
|
345
|
+
this._localStore.add(this._list.onDidChangeContentHeight(() => {
|
|
346
|
+
updateInsets();
|
|
347
|
+
}));
|
|
348
|
+
this._localStore.add(this._eventDispatcher.onDidChangeCellLayout(() => {
|
|
349
|
+
updateInsets();
|
|
350
|
+
}));
|
|
351
|
+
}
|
|
352
|
+
async _createModifiedWebview(id, viewType, resource) {
|
|
353
|
+
this._modifiedWebview?.dispose();
|
|
354
|
+
this._modifiedWebview = this.instantiationService.createInstance(BackLayerWebView, this, id, viewType, resource, {
|
|
355
|
+
...this._notebookOptions.computeDiffWebviewOptions(),
|
|
356
|
+
fontFamily: this._generateFontFamily()
|
|
357
|
+
}, undefined);
|
|
358
|
+
this._list.rowsContainer.insertAdjacentElement('afterbegin', this._modifiedWebview.element);
|
|
359
|
+
this._modifiedWebview.createWebview();
|
|
360
|
+
this._modifiedWebview.element.style.width = `calc(50% - 16px)`;
|
|
361
|
+
this._modifiedWebview.element.style.left = `calc(50%)`;
|
|
362
|
+
}
|
|
363
|
+
_generateFontFamily() {
|
|
364
|
+
return this._fontInfo?.fontFamily ?? `"SF Mono", Monaco, Menlo, Consolas, "Ubuntu Mono", "Liberation Mono", "DejaVu Sans Mono", "Courier New", monospace`;
|
|
365
|
+
}
|
|
366
|
+
async _createOriginalWebview(id, viewType, resource) {
|
|
367
|
+
this._originalWebview?.dispose();
|
|
368
|
+
this._originalWebview = this.instantiationService.createInstance(BackLayerWebView, this, id, viewType, resource, {
|
|
369
|
+
...this._notebookOptions.computeDiffWebviewOptions(),
|
|
370
|
+
fontFamily: this._generateFontFamily()
|
|
371
|
+
}, undefined);
|
|
372
|
+
this._list.rowsContainer.insertAdjacentElement('afterbegin', this._originalWebview.element);
|
|
373
|
+
this._originalWebview.createWebview();
|
|
374
|
+
this._originalWebview.element.style.width = `calc(50% - 16px)`;
|
|
375
|
+
this._originalWebview.element.style.left = `16px`;
|
|
376
|
+
}
|
|
377
|
+
setOptions(options) {
|
|
378
|
+
const selections = options?.cellSelections ? cellRangesToIndexes(options.cellSelections) : undefined;
|
|
379
|
+
if (selections) {
|
|
380
|
+
this._list.setFocus(selections);
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
async updateLayout(token, selections) {
|
|
384
|
+
if (!this._model) {
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
387
|
+
const diffResult = await this.notebookEditorWorkerService.computeDiff(this._model.original.resource, this._model.modified.resource);
|
|
388
|
+
if (token.isCancellationRequested) {
|
|
389
|
+
return;
|
|
390
|
+
}
|
|
391
|
+
NotebookTextDiffEditor_1.prettyChanges(this._model, diffResult.cellsDiff);
|
|
392
|
+
const { viewModels, firstChangeIndex } = NotebookTextDiffEditor_1.computeDiff(this.instantiationService, this.configurationService, this._model, this._eventDispatcher, diffResult, this._fontInfo);
|
|
393
|
+
const isSame = this._isViewModelTheSame(viewModels);
|
|
394
|
+
if (!isSame) {
|
|
395
|
+
this._originalWebview?.removeInsets([...this._originalWebview?.insetMapping.keys()]);
|
|
396
|
+
this._modifiedWebview?.removeInsets([...this._modifiedWebview?.insetMapping.keys()]);
|
|
397
|
+
this._setViewModel(viewModels);
|
|
398
|
+
}
|
|
399
|
+
if (this._revealFirst && firstChangeIndex !== -1 && firstChangeIndex < this._list.length) {
|
|
400
|
+
this._revealFirst = false;
|
|
401
|
+
this._list.setFocus([firstChangeIndex]);
|
|
402
|
+
this._list.reveal(firstChangeIndex, 0.3);
|
|
403
|
+
}
|
|
404
|
+
if (selections) {
|
|
405
|
+
this._list.setFocus(selections);
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
_isViewModelTheSame(viewModels) {
|
|
409
|
+
let isSame = true;
|
|
410
|
+
if (this._diffElementViewModels.length === viewModels.length) {
|
|
411
|
+
for (let i = 0; i < viewModels.length; i++) {
|
|
412
|
+
const a = this._diffElementViewModels[i];
|
|
413
|
+
const b = viewModels[i];
|
|
414
|
+
if (a.original?.textModel.getHashValue() !== b.original?.textModel.getHashValue()
|
|
415
|
+
|| a.modified?.textModel.getHashValue() !== b.modified?.textModel.getHashValue()) {
|
|
416
|
+
isSame = false;
|
|
417
|
+
break;
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
else {
|
|
422
|
+
isSame = false;
|
|
423
|
+
}
|
|
424
|
+
return isSame;
|
|
425
|
+
}
|
|
426
|
+
_setViewModel(viewModels) {
|
|
427
|
+
this._diffElementViewModels = viewModels;
|
|
428
|
+
this._list.splice(0, this._list.length, this._diffElementViewModels);
|
|
429
|
+
if (this.isOverviewRulerEnabled()) {
|
|
430
|
+
this._overviewRuler.updateViewModels(this._diffElementViewModels, this._eventDispatcher);
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
static prettyChanges(model, diffResult) {
|
|
434
|
+
const changes = diffResult.changes;
|
|
435
|
+
for (let i = 0; i < diffResult.changes.length - 1; i++) {
|
|
436
|
+
const curr = changes[i];
|
|
437
|
+
const next = changes[i + 1];
|
|
438
|
+
const x = curr.originalStart;
|
|
439
|
+
const y = curr.modifiedStart;
|
|
440
|
+
if (curr.originalLength === 1
|
|
441
|
+
&& curr.modifiedLength === 0
|
|
442
|
+
&& next.originalStart === x + 2
|
|
443
|
+
&& next.originalLength === 0
|
|
444
|
+
&& next.modifiedStart === y + 1
|
|
445
|
+
&& next.modifiedLength === 1
|
|
446
|
+
&& model.original.notebook.cells[x].getHashValue() === model.modified.notebook.cells[y + 1].getHashValue()
|
|
447
|
+
&& model.original.notebook.cells[x + 1].getHashValue() === model.modified.notebook.cells[y].getHashValue()) {
|
|
448
|
+
curr.originalStart = x;
|
|
449
|
+
curr.originalLength = 0;
|
|
450
|
+
curr.modifiedStart = y;
|
|
451
|
+
curr.modifiedLength = 1;
|
|
452
|
+
next.originalStart = x + 1;
|
|
453
|
+
next.originalLength = 1;
|
|
454
|
+
next.modifiedStart = y + 2;
|
|
455
|
+
next.modifiedLength = 0;
|
|
456
|
+
i++;
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
static computeDiff(instantiationService, configurationService, model, eventDispatcher, diffResult, fontInfo) {
|
|
461
|
+
const cellChanges = diffResult.cellsDiff.changes;
|
|
462
|
+
const diffElementViewModels = [];
|
|
463
|
+
const originalModel = model.original.notebook;
|
|
464
|
+
const modifiedModel = model.modified.notebook;
|
|
465
|
+
let originalCellIndex = 0;
|
|
466
|
+
let modifiedCellIndex = 0;
|
|
467
|
+
let firstChangeIndex = -1;
|
|
468
|
+
const initData = {
|
|
469
|
+
metadataStatusHeight: configurationService.getValue('notebook.diff.ignoreMetadata') ? 0 : 25,
|
|
470
|
+
outputStatusHeight: configurationService.getValue('notebook.diff.ignoreOutputs') || !!(modifiedModel.transientOptions.transientOutputs) ? 0 : 25,
|
|
471
|
+
fontInfo
|
|
472
|
+
};
|
|
473
|
+
for (let i = 0; i < cellChanges.length; i++) {
|
|
474
|
+
const change = cellChanges[i];
|
|
475
|
+
for (let j = 0; j < change.originalStart - originalCellIndex; j++) {
|
|
476
|
+
const originalCell = originalModel.cells[originalCellIndex + j];
|
|
477
|
+
const modifiedCell = modifiedModel.cells[modifiedCellIndex + j];
|
|
478
|
+
if (originalCell.getHashValue() === modifiedCell.getHashValue()) {
|
|
479
|
+
diffElementViewModels.push(( new SideBySideDiffElementViewModel(
|
|
480
|
+
model.modified.notebook,
|
|
481
|
+
model.original.notebook,
|
|
482
|
+
instantiationService.createInstance(DiffNestedCellViewModel, originalCell),
|
|
483
|
+
instantiationService.createInstance(DiffNestedCellViewModel, modifiedCell),
|
|
484
|
+
'unchanged',
|
|
485
|
+
eventDispatcher,
|
|
486
|
+
initData
|
|
487
|
+
)));
|
|
488
|
+
}
|
|
489
|
+
else {
|
|
490
|
+
if (firstChangeIndex === -1) {
|
|
491
|
+
firstChangeIndex = diffElementViewModels.length;
|
|
492
|
+
}
|
|
493
|
+
diffElementViewModels.push(( new SideBySideDiffElementViewModel(
|
|
494
|
+
model.modified.notebook,
|
|
495
|
+
model.original.notebook,
|
|
496
|
+
instantiationService.createInstance(DiffNestedCellViewModel, originalCell),
|
|
497
|
+
instantiationService.createInstance(DiffNestedCellViewModel, modifiedCell),
|
|
498
|
+
'modified',
|
|
499
|
+
eventDispatcher,
|
|
500
|
+
initData
|
|
501
|
+
)));
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
const modifiedLCS = NotebookTextDiffEditor_1.computeModifiedLCS(instantiationService, change, originalModel, modifiedModel, eventDispatcher, initData);
|
|
505
|
+
if (modifiedLCS.length && firstChangeIndex === -1) {
|
|
506
|
+
firstChangeIndex = diffElementViewModels.length;
|
|
507
|
+
}
|
|
508
|
+
diffElementViewModels.push(...modifiedLCS);
|
|
509
|
+
originalCellIndex = change.originalStart + change.originalLength;
|
|
510
|
+
modifiedCellIndex = change.modifiedStart + change.modifiedLength;
|
|
511
|
+
}
|
|
512
|
+
for (let i = originalCellIndex; i < originalModel.cells.length; i++) {
|
|
513
|
+
diffElementViewModels.push(( new SideBySideDiffElementViewModel(
|
|
514
|
+
model.modified.notebook,
|
|
515
|
+
model.original.notebook,
|
|
516
|
+
instantiationService.createInstance(DiffNestedCellViewModel, originalModel.cells[i]),
|
|
517
|
+
instantiationService.createInstance(DiffNestedCellViewModel, modifiedModel.cells[i - originalCellIndex + modifiedCellIndex]),
|
|
518
|
+
'unchanged',
|
|
519
|
+
eventDispatcher,
|
|
520
|
+
initData
|
|
521
|
+
)));
|
|
522
|
+
}
|
|
523
|
+
return {
|
|
524
|
+
viewModels: diffElementViewModels,
|
|
525
|
+
firstChangeIndex
|
|
526
|
+
};
|
|
527
|
+
}
|
|
528
|
+
static computeModifiedLCS(instantiationService, change, originalModel, modifiedModel, eventDispatcher, initData) {
|
|
529
|
+
const result = [];
|
|
530
|
+
const modifiedLen = Math.min(change.originalLength, change.modifiedLength);
|
|
531
|
+
for (let j = 0; j < modifiedLen; j++) {
|
|
532
|
+
const isTheSame = originalModel.cells[change.originalStart + j].equal(modifiedModel.cells[change.modifiedStart + j]);
|
|
533
|
+
result.push(( new SideBySideDiffElementViewModel(
|
|
534
|
+
modifiedModel,
|
|
535
|
+
originalModel,
|
|
536
|
+
instantiationService.createInstance(DiffNestedCellViewModel, originalModel.cells[change.originalStart + j]),
|
|
537
|
+
instantiationService.createInstance(DiffNestedCellViewModel, modifiedModel.cells[change.modifiedStart + j]),
|
|
538
|
+
isTheSame ? 'unchanged' : 'modified',
|
|
539
|
+
eventDispatcher,
|
|
540
|
+
initData
|
|
541
|
+
)));
|
|
542
|
+
}
|
|
543
|
+
for (let j = modifiedLen; j < change.originalLength; j++) {
|
|
544
|
+
result.push(( new SingleSideDiffElementViewModel(
|
|
545
|
+
originalModel,
|
|
546
|
+
modifiedModel,
|
|
547
|
+
instantiationService.createInstance(DiffNestedCellViewModel, originalModel.cells[change.originalStart + j]),
|
|
548
|
+
undefined,
|
|
549
|
+
'delete',
|
|
550
|
+
eventDispatcher,
|
|
551
|
+
initData
|
|
552
|
+
)));
|
|
553
|
+
}
|
|
554
|
+
for (let j = modifiedLen; j < change.modifiedLength; j++) {
|
|
555
|
+
result.push(( new SingleSideDiffElementViewModel(
|
|
556
|
+
modifiedModel,
|
|
557
|
+
originalModel,
|
|
558
|
+
undefined,
|
|
559
|
+
instantiationService.createInstance(DiffNestedCellViewModel, modifiedModel.cells[change.modifiedStart + j]),
|
|
560
|
+
'insert',
|
|
561
|
+
eventDispatcher,
|
|
562
|
+
initData
|
|
563
|
+
)));
|
|
564
|
+
}
|
|
565
|
+
return result;
|
|
566
|
+
}
|
|
567
|
+
scheduleOutputHeightAck(cellInfo, outputId, height) {
|
|
568
|
+
const diffElement = cellInfo.diffElement;
|
|
569
|
+
let diffSide = DiffSide.Original;
|
|
570
|
+
if (diffElement instanceof SideBySideDiffElementViewModel) {
|
|
571
|
+
const info = CellUri.parse(cellInfo.cellUri);
|
|
572
|
+
if (!info) {
|
|
573
|
+
return;
|
|
574
|
+
}
|
|
575
|
+
diffSide = ( info.notebook.toString()) === this._model?.original.resource.toString() ? DiffSide.Original : DiffSide.Modified;
|
|
576
|
+
}
|
|
577
|
+
else {
|
|
578
|
+
diffSide = diffElement.type === 'insert' ? DiffSide.Modified : DiffSide.Original;
|
|
579
|
+
}
|
|
580
|
+
const webview = diffSide === DiffSide.Modified ? this._modifiedWebview : this._originalWebview;
|
|
581
|
+
dom.scheduleAtNextAnimationFrame(dom.getWindow(this._listViewContainer), () => {
|
|
582
|
+
webview?.ackHeight([{ cellId: cellInfo.cellId, outputId, height }]);
|
|
583
|
+
}, 10);
|
|
584
|
+
}
|
|
585
|
+
layoutNotebookCell(cell, height) {
|
|
586
|
+
const relayout = (cell, height) => {
|
|
587
|
+
this._list.updateElementHeight2(cell, height);
|
|
588
|
+
};
|
|
589
|
+
if (( this.pendingLayouts.has(cell))) {
|
|
590
|
+
this.pendingLayouts.get(cell).dispose();
|
|
591
|
+
}
|
|
592
|
+
let r;
|
|
593
|
+
const layoutDisposable = dom.scheduleAtNextAnimationFrame(dom.getWindow(this._listViewContainer), () => {
|
|
594
|
+
this.pendingLayouts.delete(cell);
|
|
595
|
+
relayout(cell, height);
|
|
596
|
+
r();
|
|
597
|
+
});
|
|
598
|
+
this.pendingLayouts.set(cell, toDisposable(() => {
|
|
599
|
+
layoutDisposable.dispose();
|
|
600
|
+
r();
|
|
601
|
+
}));
|
|
602
|
+
return ( new Promise(resolve => { r = resolve; }));
|
|
603
|
+
}
|
|
604
|
+
setScrollTop(scrollTop) {
|
|
605
|
+
this._list.scrollTop = scrollTop;
|
|
606
|
+
}
|
|
607
|
+
triggerScroll(event) {
|
|
608
|
+
this._list.triggerScrollFromMouseWheelEvent(event);
|
|
609
|
+
}
|
|
610
|
+
previousChange() {
|
|
611
|
+
let currFocus = this._list.getFocus()[0];
|
|
612
|
+
if (isNaN(currFocus) || currFocus < 0) {
|
|
613
|
+
currFocus = 0;
|
|
614
|
+
}
|
|
615
|
+
let prevChangeIndex = currFocus - 1;
|
|
616
|
+
while (prevChangeIndex >= 0) {
|
|
617
|
+
const vm = this._diffElementViewModels[prevChangeIndex];
|
|
618
|
+
if (vm.type !== 'unchanged') {
|
|
619
|
+
break;
|
|
620
|
+
}
|
|
621
|
+
prevChangeIndex--;
|
|
622
|
+
}
|
|
623
|
+
if (prevChangeIndex >= 0) {
|
|
624
|
+
this._list.setFocus([prevChangeIndex]);
|
|
625
|
+
this._list.reveal(prevChangeIndex);
|
|
626
|
+
}
|
|
627
|
+
else {
|
|
628
|
+
const index = findLastIdx(this._diffElementViewModels, vm => vm.type !== 'unchanged');
|
|
629
|
+
if (index >= 0) {
|
|
630
|
+
this._list.setFocus([index]);
|
|
631
|
+
this._list.reveal(index);
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
nextChange() {
|
|
636
|
+
let currFocus = this._list.getFocus()[0];
|
|
637
|
+
if (isNaN(currFocus) || currFocus < 0) {
|
|
638
|
+
currFocus = 0;
|
|
639
|
+
}
|
|
640
|
+
let nextChangeIndex = currFocus + 1;
|
|
641
|
+
while (nextChangeIndex < this._diffElementViewModels.length) {
|
|
642
|
+
const vm = this._diffElementViewModels[nextChangeIndex];
|
|
643
|
+
if (vm.type !== 'unchanged') {
|
|
644
|
+
break;
|
|
645
|
+
}
|
|
646
|
+
nextChangeIndex++;
|
|
647
|
+
}
|
|
648
|
+
if (nextChangeIndex < this._diffElementViewModels.length) {
|
|
649
|
+
this._list.setFocus([nextChangeIndex]);
|
|
650
|
+
this._list.reveal(nextChangeIndex);
|
|
651
|
+
}
|
|
652
|
+
else {
|
|
653
|
+
const index = this._diffElementViewModels.findIndex(vm => vm.type !== 'unchanged');
|
|
654
|
+
if (index >= 0) {
|
|
655
|
+
this._list.setFocus([index]);
|
|
656
|
+
this._list.reveal(index);
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
createOutput(cellDiffViewModel, cellViewModel, output, getOffset, diffSide) {
|
|
661
|
+
this._insetModifyQueueByOutputId.queue(output.source.model.outputId + (diffSide === DiffSide.Modified ? '-right' : 'left'), async () => {
|
|
662
|
+
const activeWebview = diffSide === DiffSide.Modified ? this._modifiedWebview : this._originalWebview;
|
|
663
|
+
if (!activeWebview) {
|
|
664
|
+
return;
|
|
665
|
+
}
|
|
666
|
+
if (!( activeWebview.insetMapping.has(output.source))) {
|
|
667
|
+
const cellTop = this._list.getCellViewScrollTop(cellDiffViewModel);
|
|
668
|
+
await activeWebview.createOutput({ diffElement: cellDiffViewModel, cellHandle: cellViewModel.handle, cellId: cellViewModel.id, cellUri: cellViewModel.uri }, output, cellTop, getOffset());
|
|
669
|
+
}
|
|
670
|
+
else {
|
|
671
|
+
const cellTop = this._list.getCellViewScrollTop(cellDiffViewModel);
|
|
672
|
+
const outputIndex = cellViewModel.outputsViewModels.indexOf(output.source);
|
|
673
|
+
const outputOffset = cellDiffViewModel.getOutputOffsetInCell(diffSide, outputIndex);
|
|
674
|
+
activeWebview.updateScrollTops([{
|
|
675
|
+
cell: cellViewModel,
|
|
676
|
+
output: output.source,
|
|
677
|
+
cellTop,
|
|
678
|
+
outputOffset,
|
|
679
|
+
forceDisplay: true
|
|
680
|
+
}], []);
|
|
681
|
+
}
|
|
682
|
+
});
|
|
683
|
+
}
|
|
684
|
+
updateMarkupCellHeight() {
|
|
685
|
+
}
|
|
686
|
+
getCellByInfo(cellInfo) {
|
|
687
|
+
return cellInfo.diffElement.getCellByUri(cellInfo.cellUri);
|
|
688
|
+
}
|
|
689
|
+
getCellById(cellId) {
|
|
690
|
+
throw new Error('Not implemented');
|
|
691
|
+
}
|
|
692
|
+
removeInset(cellDiffViewModel, cellViewModel, displayOutput, diffSide) {
|
|
693
|
+
this._insetModifyQueueByOutputId.queue(displayOutput.model.outputId + (diffSide === DiffSide.Modified ? '-right' : 'left'), async () => {
|
|
694
|
+
const activeWebview = diffSide === DiffSide.Modified ? this._modifiedWebview : this._originalWebview;
|
|
695
|
+
if (!activeWebview) {
|
|
696
|
+
return;
|
|
697
|
+
}
|
|
698
|
+
if (!( activeWebview.insetMapping.has(displayOutput))) {
|
|
699
|
+
return;
|
|
700
|
+
}
|
|
701
|
+
activeWebview.removeInsets([displayOutput]);
|
|
702
|
+
});
|
|
703
|
+
}
|
|
704
|
+
showInset(cellDiffViewModel, cellViewModel, displayOutput, diffSide) {
|
|
705
|
+
this._insetModifyQueueByOutputId.queue(displayOutput.model.outputId + (diffSide === DiffSide.Modified ? '-right' : 'left'), async () => {
|
|
706
|
+
const activeWebview = diffSide === DiffSide.Modified ? this._modifiedWebview : this._originalWebview;
|
|
707
|
+
if (!activeWebview) {
|
|
708
|
+
return;
|
|
709
|
+
}
|
|
710
|
+
if (!( activeWebview.insetMapping.has(displayOutput))) {
|
|
711
|
+
return;
|
|
712
|
+
}
|
|
713
|
+
const cellTop = this._list.getCellViewScrollTop(cellDiffViewModel);
|
|
714
|
+
const outputIndex = cellViewModel.outputsViewModels.indexOf(displayOutput);
|
|
715
|
+
const outputOffset = cellDiffViewModel.getOutputOffsetInCell(diffSide, outputIndex);
|
|
716
|
+
activeWebview.updateScrollTops([{
|
|
717
|
+
cell: cellViewModel,
|
|
718
|
+
output: displayOutput,
|
|
719
|
+
cellTop,
|
|
720
|
+
outputOffset,
|
|
721
|
+
forceDisplay: true,
|
|
722
|
+
}], []);
|
|
723
|
+
});
|
|
724
|
+
}
|
|
725
|
+
hideInset(cellDiffViewModel, cellViewModel, output) {
|
|
726
|
+
this._modifiedWebview?.hideInset(output);
|
|
727
|
+
this._originalWebview?.hideInset(output);
|
|
728
|
+
}
|
|
729
|
+
getDomNode() {
|
|
730
|
+
return this._rootElement;
|
|
731
|
+
}
|
|
732
|
+
getOverflowContainerDomNode() {
|
|
733
|
+
return this._overflowContainer;
|
|
734
|
+
}
|
|
735
|
+
getControl() {
|
|
736
|
+
return this;
|
|
737
|
+
}
|
|
738
|
+
setEditorVisible(visible, group) {
|
|
739
|
+
super.setEditorVisible(visible, group);
|
|
740
|
+
}
|
|
741
|
+
clearInput() {
|
|
742
|
+
super.clearInput();
|
|
743
|
+
this._modifiedResourceDisposableStore.clear();
|
|
744
|
+
this._list?.splice(0, this._list?.length || 0);
|
|
745
|
+
this._model = null;
|
|
746
|
+
this._diffElementViewModels.forEach(vm => vm.dispose());
|
|
747
|
+
this._diffElementViewModels = [];
|
|
748
|
+
}
|
|
749
|
+
deltaCellOutputContainerClassNames(diffSide, cellId, added, removed) {
|
|
750
|
+
if (diffSide === DiffSide.Original) {
|
|
751
|
+
this._originalWebview?.deltaCellContainerClassNames(cellId, added, removed);
|
|
752
|
+
}
|
|
753
|
+
else {
|
|
754
|
+
this._modifiedWebview?.deltaCellContainerClassNames(cellId, added, removed);
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
getLayoutInfo() {
|
|
758
|
+
if (!this._list) {
|
|
759
|
+
throw new Error('Editor is not initalized successfully');
|
|
760
|
+
}
|
|
761
|
+
return {
|
|
762
|
+
width: this._dimension.width,
|
|
763
|
+
height: this._dimension.height,
|
|
764
|
+
fontInfo: this._fontInfo,
|
|
765
|
+
scrollHeight: this._list?.getScrollHeight() ?? 0,
|
|
766
|
+
stickyHeight: 0,
|
|
767
|
+
};
|
|
768
|
+
}
|
|
769
|
+
getCellOutputLayoutInfo(nestedCell) {
|
|
770
|
+
if (!this._model) {
|
|
771
|
+
throw new Error('Editor is not attached to model yet');
|
|
772
|
+
}
|
|
773
|
+
const documentModel = CellUri.parse(nestedCell.uri);
|
|
774
|
+
if (!documentModel) {
|
|
775
|
+
throw new Error('Nested cell in the diff editor has wrong Uri');
|
|
776
|
+
}
|
|
777
|
+
const belongToOriginalDocument = ( this._model.original.notebook.uri.toString()) === ( documentModel.notebook.toString());
|
|
778
|
+
const viewModel = this._diffElementViewModels.find(element => {
|
|
779
|
+
const textModel = belongToOriginalDocument ? element.original : element.modified;
|
|
780
|
+
if (!textModel) {
|
|
781
|
+
return false;
|
|
782
|
+
}
|
|
783
|
+
if (( textModel.uri.toString()) === ( nestedCell.uri.toString())) {
|
|
784
|
+
return true;
|
|
785
|
+
}
|
|
786
|
+
return false;
|
|
787
|
+
});
|
|
788
|
+
if (!viewModel) {
|
|
789
|
+
throw new Error('Nested cell in the diff editor does not match any diff element');
|
|
790
|
+
}
|
|
791
|
+
if (viewModel.type === 'unchanged') {
|
|
792
|
+
return this.getLayoutInfo();
|
|
793
|
+
}
|
|
794
|
+
if (viewModel.type === 'insert' || viewModel.type === 'delete') {
|
|
795
|
+
return {
|
|
796
|
+
width: this._dimension.width / 2,
|
|
797
|
+
height: this._dimension.height / 2,
|
|
798
|
+
fontInfo: this._fontInfo
|
|
799
|
+
};
|
|
800
|
+
}
|
|
801
|
+
if (viewModel.checkIfOutputsModified()) {
|
|
802
|
+
return {
|
|
803
|
+
width: this._dimension.width / 2,
|
|
804
|
+
height: this._dimension.height / 2,
|
|
805
|
+
fontInfo: this._fontInfo
|
|
806
|
+
};
|
|
807
|
+
}
|
|
808
|
+
else {
|
|
809
|
+
return this.getLayoutInfo();
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
layout(dimension, _position) {
|
|
813
|
+
this._rootElement.classList.toggle('mid-width', dimension.width < 1000 && dimension.width >= 600);
|
|
814
|
+
this._rootElement.classList.toggle('narrow-width', dimension.width < 600);
|
|
815
|
+
const overviewRulerEnabled = this.isOverviewRulerEnabled();
|
|
816
|
+
this._dimension = dimension.with(dimension.width - (overviewRulerEnabled ? NotebookTextDiffEditor_1.ENTIRE_DIFF_OVERVIEW_WIDTH : 0));
|
|
817
|
+
this._listViewContainer.style.height = `${dimension.height}px`;
|
|
818
|
+
this._listViewContainer.style.width = `${this._dimension.width}px`;
|
|
819
|
+
this._list?.layout(this._dimension.height, this._dimension.width);
|
|
820
|
+
if (this._modifiedWebview) {
|
|
821
|
+
this._modifiedWebview.element.style.width = `calc(50% - 16px)`;
|
|
822
|
+
this._modifiedWebview.element.style.left = `calc(50%)`;
|
|
823
|
+
}
|
|
824
|
+
if (this._originalWebview) {
|
|
825
|
+
this._originalWebview.element.style.width = `calc(50% - 16px)`;
|
|
826
|
+
this._originalWebview.element.style.left = `16px`;
|
|
827
|
+
}
|
|
828
|
+
if (this._webviewTransparentCover) {
|
|
829
|
+
this._webviewTransparentCover.style.height = `${this._dimension.height}px`;
|
|
830
|
+
this._webviewTransparentCover.style.width = `${this._dimension.width}px`;
|
|
831
|
+
}
|
|
832
|
+
if (overviewRulerEnabled) {
|
|
833
|
+
this._overviewRuler.layout();
|
|
834
|
+
}
|
|
835
|
+
this._eventDispatcher?.emit([( new NotebookDiffLayoutChangedEvent({ width: true, fontInfo: true }, this.getLayoutInfo()))]);
|
|
836
|
+
}
|
|
837
|
+
dispose() {
|
|
838
|
+
this._isDisposed = true;
|
|
839
|
+
this._layoutCancellationTokenSource?.dispose();
|
|
840
|
+
this._detachModel();
|
|
841
|
+
super.dispose();
|
|
842
|
+
}
|
|
843
|
+
};
|
|
844
|
+
NotebookTextDiffEditor = NotebookTextDiffEditor_1 = ( __decorate([
|
|
845
|
+
( __param(0, IInstantiationService)),
|
|
846
|
+
( __param(1, IThemeService)),
|
|
847
|
+
( __param(2, IContextKeyService)),
|
|
848
|
+
( __param(3, INotebookEditorWorkerService)),
|
|
849
|
+
( __param(4, IConfigurationService)),
|
|
850
|
+
( __param(5, ITelemetryService)),
|
|
851
|
+
( __param(6, IStorageService)),
|
|
852
|
+
( __param(7, INotebookExecutionStateService))
|
|
853
|
+
], NotebookTextDiffEditor));
|
|
854
|
+
registerZIndex(ZIndex.Base, 10, 'notebook-diff-view-viewport-slider');
|
|
855
|
+
registerThemingParticipant((theme, collector) => {
|
|
856
|
+
const diffDiagonalFillColor = theme.getColor(diffDiagonalFill);
|
|
857
|
+
collector.addRule(`
|
|
858
|
+
.notebook-text-diff-editor .diagonal-fill {
|
|
859
|
+
background-image: linear-gradient(
|
|
860
|
+
-45deg,
|
|
861
|
+
${diffDiagonalFillColor} 12.5%,
|
|
862
|
+
#0000 12.5%, #0000 50%,
|
|
863
|
+
${diffDiagonalFillColor} 50%, ${diffDiagonalFillColor} 62.5%,
|
|
864
|
+
#0000 62.5%, #0000 100%
|
|
865
|
+
);
|
|
866
|
+
background-size: 8px 8px;
|
|
867
|
+
}
|
|
868
|
+
`);
|
|
869
|
+
collector.addRule(`.notebook-text-diff-editor .cell-body { margin: ${DIFF_CELL_MARGIN}px; }`);
|
|
870
|
+
});
|
|
871
|
+
|
|
872
|
+
export { NotebookTextDiffEditor };
|