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