@codingame/monaco-vscode-api 33.0.3 → 33.0.5

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.
Files changed (52) hide show
  1. package/package.json +9 -9
  2. package/services.js +3 -3
  3. package/vscode/src/vs/platform/product/common/product.js +1 -1
  4. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/cellOperations.d.ts +0 -26
  5. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/cellOperations.js +0 -746
  6. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/insertCellActions.d.ts +0 -13
  7. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/insertCellActions.js +0 -300
  8. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffCellEditorOptions.d.ts +0 -8
  9. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffCellEditorOptions.js +0 -55
  10. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffComponents.d.ts +0 -273
  11. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffComponents.js +0 -1963
  12. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffElementOutputs.d.ts +0 -50
  13. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffElementOutputs.js +0 -314
  14. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffElementViewModel.d.ts +0 -258
  15. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffElementViewModel.js +0 -886
  16. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffNestedCellViewModel.d.ts +0 -41
  17. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffNestedCellViewModel.js +0 -118
  18. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/editorHeightCalculator.d.ts +0 -17
  19. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/editorHeightCalculator.js +0 -71
  20. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/eventDispatcher.d.ts +0 -27
  21. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/eventDispatcher.js +0 -40
  22. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookCellDiffDecorator.d.ts +0 -23
  23. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookCellDiffDecorator.js +0 -313
  24. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookDeletedCellDecorator.d.ts +0 -51
  25. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookDeletedCellDecorator.js +0 -265
  26. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookInlineDiff.d.ts +0 -24
  27. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookInlineDiff.js +0 -185
  28. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookInlineDiffWidget.d.ts +0 -28
  29. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookInlineDiffWidget.js +0 -104
  30. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookInsertedCellDecorator.d.ts +0 -10
  31. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookInsertedCellDecorator.js +0 -43
  32. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookOriginalCellModelFactory.d.ts +0 -21
  33. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookOriginalCellModelFactory.js +0 -41
  34. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookOriginalModelRefFactory.d.ts +0 -25
  35. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookOriginalModelRefFactory.js +0 -69
  36. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiff.css +0 -469
  37. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffEditor.d.ts +0 -149
  38. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffEditor.js +0 -933
  39. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffEditorBrowser.d.ts +0 -180
  40. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffEditorBrowser.js +0 -32
  41. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffList.d.ts +0 -102
  42. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffList.js +0 -643
  43. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffOverviewRuler.d.ts +0 -30
  44. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffOverviewRuler.js +0 -197
  45. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffViewModel.d.ts +0 -75
  46. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffViewModel.js +0 -539
  47. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/unchangedEditorRegions.d.ts +0 -13
  48. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/unchangedEditorRegions.js +0 -39
  49. package/vscode/src/vs/workbench/contrib/notebook/common/model/notebookMetadataTextModel.d.ts +0 -19
  50. package/vscode/src/vs/workbench/contrib/notebook/common/model/notebookMetadataTextModel.js +0 -90
  51. package/vscode/src/vs/workbench/contrib/notebook/common/notebookDiff.d.ts +0 -26
  52. package/vscode/src/vs/workbench/contrib/notebook/common/notebookDiff.js +0 -92
@@ -1,41 +0,0 @@
1
- import { Emitter } from "../../../../../base/common/event.js";
2
- import { Disposable } from "../../../../../base/common/lifecycle.js";
3
- import { PrefixSumComputer } from "../../../../../editor/common/model/prefixSumComputer.js";
4
- import { IDiffNestedCellViewModel } from "./notebookDiffEditorBrowser.js";
5
- import { ICellOutputViewModel, IGenericCellViewModel } from "../notebookBrowser.js";
6
- import { CellViewModelStateChangeEvent } from "../notebookViewEvents.js";
7
- import { NotebookCellTextModel } from "../../common/model/notebookCellTextModel.js";
8
- import { INotebookService } from "../../common/notebookService.service.js";
9
- export declare class DiffNestedCellViewModel extends Disposable implements IDiffNestedCellViewModel, IGenericCellViewModel {
10
- readonly textModel: NotebookCellTextModel;
11
- private _notebookService;
12
- private _id;
13
- get id(): string;
14
- get outputs(): import("../../common/notebookCommon.js").ICellOutput[];
15
- get language(): string;
16
- get metadata(): import("../../common/notebookCommon.js").NotebookCellMetadata;
17
- get uri(): import("../../../../../base/common/uri.js").URI;
18
- get handle(): number;
19
- protected readonly _onDidChangeState: Emitter<CellViewModelStateChangeEvent>;
20
- private _hoveringOutput;
21
- get outputIsHovered(): boolean;
22
- set outputIsHovered(v: boolean);
23
- private _focusOnOutput;
24
- get outputIsFocused(): boolean;
25
- set outputIsFocused(v: boolean);
26
- private _focusInputInOutput;
27
- get inputInOutputIsFocused(): boolean;
28
- set inputInOutputIsFocused(v: boolean);
29
- private _outputViewModels;
30
- get outputsViewModels(): ICellOutputViewModel[];
31
- protected _outputCollection: number[];
32
- protected _outputsTop: PrefixSumComputer | null;
33
- protected readonly _onDidChangeOutputLayout: Emitter<void>;
34
- readonly onDidChangeOutputLayout: import("../../../../../base/common/event.js").Event<void>;
35
- constructor(textModel: NotebookCellTextModel, _notebookService: INotebookService);
36
- private _ensureOutputsTop;
37
- getOutputOffset(index: number): number;
38
- updateOutputHeight(index: number, height: number): void;
39
- getOutputTotalHeight(): number;
40
- dispose(): void;
41
- }
@@ -1,118 +0,0 @@
1
-
2
- import { __decorate, __param } from '../../../../../../../../external/tslib/tslib.es6.js';
3
- import { Emitter } from '../../../../../base/common/event.js';
4
- import { Disposable } from '../../../../../base/common/lifecycle.js';
5
- import { generateUuid } from '../../../../../base/common/uuid.js';
6
- import { PrefixSumComputer } from '../../../../../editor/common/model/prefixSumComputer.js';
7
- import { CellOutputViewModel } from '../viewModel/cellOutputViewModel.js';
8
- import { INotebookService } from '../../common/notebookService.service.js';
9
-
10
- let DiffNestedCellViewModel = class DiffNestedCellViewModel extends Disposable {
11
- get id() {
12
- return this._id;
13
- }
14
- get outputs() {
15
- return this.textModel.outputs;
16
- }
17
- get language() {
18
- return this.textModel.language;
19
- }
20
- get metadata() {
21
- return this.textModel.metadata;
22
- }
23
- get uri() {
24
- return this.textModel.uri;
25
- }
26
- get handle() {
27
- return this.textModel.handle;
28
- }
29
- get outputIsHovered() {
30
- return this._hoveringOutput;
31
- }
32
- set outputIsHovered(v) {
33
- this._hoveringOutput = v;
34
- this._onDidChangeState.fire({
35
- outputIsHoveredChanged: true
36
- });
37
- }
38
- get outputIsFocused() {
39
- return this._focusOnOutput;
40
- }
41
- set outputIsFocused(v) {
42
- this._focusOnOutput = v;
43
- this._onDidChangeState.fire({
44
- outputIsFocusedChanged: true
45
- });
46
- }
47
- get inputInOutputIsFocused() {
48
- return this._focusInputInOutput;
49
- }
50
- set inputInOutputIsFocused(v) {
51
- this._focusInputInOutput = v;
52
- }
53
- get outputsViewModels() {
54
- return this._outputViewModels;
55
- }
56
- constructor(textModel, _notebookService) {
57
- super();
58
- this.textModel = textModel;
59
- this._notebookService = _notebookService;
60
- this._onDidChangeState = this._register(( new Emitter()));
61
- this._hoveringOutput = false;
62
- this._focusOnOutput = false;
63
- this._focusInputInOutput = false;
64
- this._outputCollection = [];
65
- this._outputsTop = null;
66
- this._onDidChangeOutputLayout = this._register(( new Emitter()));
67
- this.onDidChangeOutputLayout = this._onDidChangeOutputLayout.event;
68
- this._id = generateUuid();
69
- this._outputViewModels = ( this.textModel.outputs.map(output => ( new CellOutputViewModel(this, output, this._notebookService))));
70
- this._register(this.textModel.onDidChangeOutputs(splice => {
71
- this._outputCollection.splice(splice.start, splice.deleteCount, ...( splice.newOutputs.map(() => 0)));
72
- const removed = this._outputViewModels.splice(splice.start, splice.deleteCount, ...( splice.newOutputs.map(output => ( new CellOutputViewModel(this, output, this._notebookService)))));
73
- removed.forEach(vm => vm.dispose());
74
- this._outputsTop = null;
75
- this._onDidChangeOutputLayout.fire();
76
- }));
77
- this._outputCollection = ( new Array(this.textModel.outputs.length));
78
- }
79
- _ensureOutputsTop() {
80
- if (!this._outputsTop) {
81
- const values = ( new Uint32Array(this._outputCollection.length));
82
- for (let i = 0; i < this._outputCollection.length; i++) {
83
- values[i] = this._outputCollection[i];
84
- }
85
- this._outputsTop = ( new PrefixSumComputer(values));
86
- }
87
- }
88
- getOutputOffset(index) {
89
- this._ensureOutputsTop();
90
- if (index >= this._outputCollection.length) {
91
- throw ( new Error("Output index out of range!"));
92
- }
93
- return this._outputsTop.getPrefixSum(index - 1);
94
- }
95
- updateOutputHeight(index, height) {
96
- if (index >= this._outputCollection.length) {
97
- throw ( new Error("Output index out of range!"));
98
- }
99
- this._ensureOutputsTop();
100
- this._outputCollection[index] = height;
101
- if (this._outputsTop.setValue(index, height)) {
102
- this._onDidChangeOutputLayout.fire();
103
- }
104
- }
105
- getOutputTotalHeight() {
106
- this._ensureOutputsTop();
107
- return this._outputsTop?.getTotalSum() ?? 0;
108
- }
109
- dispose() {
110
- super.dispose();
111
- this._outputViewModels.forEach(output => {
112
- output.dispose();
113
- });
114
- }
115
- };
116
- DiffNestedCellViewModel = ( __decorate([( __param(1, INotebookService))], DiffNestedCellViewModel));
117
-
118
- export { DiffNestedCellViewModel };
@@ -1,17 +0,0 @@
1
- import { URI } from "../../../../../base/common/uri.js";
2
- import { IEditorWorkerService } from "../../../../../editor/common/services/editorWorker.service.js";
3
- import { ITextModelService } from "../../../../../editor/common/services/resolverService.service.js";
4
- import { IConfigurationService } from "../../../../../platform/configuration/common/configuration.service.js";
5
- export interface IDiffEditorHeightCalculatorService {
6
- diffAndComputeHeight(original: URI, modified: URI): Promise<number>;
7
- computeHeightFromLines(lineCount: number): number;
8
- }
9
- export declare class DiffEditorHeightCalculatorService {
10
- private readonly lineHeight;
11
- private readonly textModelResolverService;
12
- private readonly editorWorkerService;
13
- private readonly configurationService;
14
- constructor(lineHeight: number, textModelResolverService: ITextModelService, editorWorkerService: IEditorWorkerService, configurationService: IConfigurationService);
15
- diffAndComputeHeight(original: URI, modified: URI): Promise<number>;
16
- computeHeightFromLines(lineCount: number): number;
17
- }
@@ -1,71 +0,0 @@
1
-
2
- import { __decorate, __param } from '../../../../../../../../external/tslib/tslib.es6.js';
3
- import { UnchangedRegion } from '../../../../../editor/browser/widget/diffEditor/diffEditorViewModel.js';
4
- import { IEditorWorkerService } from '../../../../../editor/common/services/editorWorker.service.js';
5
- import { ITextModelService } from '../../../../../editor/common/services/resolverService.service.js';
6
- import { IConfigurationService } from '../../../../../platform/configuration/common/configuration.service.js';
7
- import { getEditorPadding } from './diffCellEditorOptions.js';
8
- import { HeightOfHiddenLinesRegionInDiffEditor } from './diffElementViewModel.js';
9
-
10
- let DiffEditorHeightCalculatorService = class DiffEditorHeightCalculatorService {
11
- constructor(
12
- lineHeight,
13
- textModelResolverService,
14
- editorWorkerService,
15
- configurationService
16
- ) {
17
- this.lineHeight = lineHeight;
18
- this.textModelResolverService = textModelResolverService;
19
- this.editorWorkerService = editorWorkerService;
20
- this.configurationService = configurationService;
21
- }
22
- async diffAndComputeHeight(original, modified) {
23
- const [originalModel, modifiedModel] = await Promise.all([
24
- this.textModelResolverService.createModelReference(original),
25
- this.textModelResolverService.createModelReference(modified)
26
- ]);
27
- try {
28
- const diffChanges = await this.editorWorkerService.computeDiff(original, modified, {
29
- ignoreTrimWhitespace: true,
30
- maxComputationTimeMs: 0,
31
- computeMoves: false
32
- }, "advanced").then(diff => diff?.changes || []);
33
- const unchangedRegionFeatureEnabled = this.configurationService.getValue("diffEditor.hideUnchangedRegions.enabled");
34
- const minimumLineCount = this.configurationService.getValue("diffEditor.hideUnchangedRegions.minimumLineCount");
35
- const contextLineCount = this.configurationService.getValue("diffEditor.hideUnchangedRegions.contextLineCount");
36
- const originalLineCount = originalModel.object.textEditorModel.getLineCount();
37
- const modifiedLineCount = modifiedModel.object.textEditorModel.getLineCount();
38
- const unchanged = unchangedRegionFeatureEnabled ? UnchangedRegion.fromDiffs(
39
- diffChanges,
40
- originalLineCount,
41
- modifiedLineCount,
42
- minimumLineCount ?? 3,
43
- contextLineCount ?? 3
44
- ) : [];
45
- const numberOfNewLines = diffChanges.reduce((prev, curr) => {
46
- if (curr.original.isEmpty && !curr.modified.isEmpty) {
47
- return prev + curr.modified.length;
48
- }
49
- if (!curr.original.isEmpty && !curr.modified.isEmpty && curr.modified.length > curr.original.length) {
50
- return prev + curr.modified.length - curr.original.length;
51
- }
52
- return prev;
53
- }, 0);
54
- const orginalNumberOfLines = originalModel.object.textEditorModel.getLineCount();
55
- const numberOfHiddenLines = unchanged.reduce((prev, curr) => prev + curr.lineCount, 0);
56
- const numberOfHiddenSections = unchanged.length;
57
- const unchangeRegionsHeight = numberOfHiddenSections * HeightOfHiddenLinesRegionInDiffEditor;
58
- const visibleLineCount = orginalNumberOfLines + numberOfNewLines - numberOfHiddenLines;
59
- return (visibleLineCount * this.lineHeight) + getEditorPadding(visibleLineCount).top + getEditorPadding(visibleLineCount).bottom + unchangeRegionsHeight;
60
- } finally {
61
- originalModel.dispose();
62
- modifiedModel.dispose();
63
- }
64
- }
65
- computeHeightFromLines(lineCount) {
66
- return lineCount * this.lineHeight + getEditorPadding(lineCount).top + getEditorPadding(lineCount).bottom;
67
- }
68
- };
69
- DiffEditorHeightCalculatorService = ( __decorate([( __param(1, ITextModelService)), ( __param(2, IEditorWorkerService)), ( __param(3, IConfigurationService))], DiffEditorHeightCalculatorService));
70
-
71
- export { DiffEditorHeightCalculatorService };
@@ -1,27 +0,0 @@
1
- import { Emitter } from "../../../../../base/common/event.js";
2
- import { Disposable } from "../../../../../base/common/lifecycle.js";
3
- import { IDiffElementLayoutInfo } from "./notebookDiffEditorBrowser.js";
4
- import { NotebookLayoutChangeEvent, NotebookLayoutInfo } from "../notebookViewEvents.js";
5
- export declare enum NotebookDiffViewEventType {
6
- LayoutChanged = 1,
7
- CellLayoutChanged = 2
8
- }
9
- export declare class NotebookDiffLayoutChangedEvent {
10
- readonly source: NotebookLayoutChangeEvent;
11
- readonly value: NotebookLayoutInfo;
12
- readonly type = NotebookDiffViewEventType.LayoutChanged;
13
- constructor(source: NotebookLayoutChangeEvent, value: NotebookLayoutInfo);
14
- }
15
- export declare class NotebookCellLayoutChangedEvent {
16
- readonly source: IDiffElementLayoutInfo;
17
- readonly type = NotebookDiffViewEventType.CellLayoutChanged;
18
- constructor(source: IDiffElementLayoutInfo);
19
- }
20
- export type NotebookDiffViewEvent = NotebookDiffLayoutChangedEvent | NotebookCellLayoutChangedEvent;
21
- export declare class NotebookDiffEditorEventDispatcher extends Disposable {
22
- protected readonly _onDidChangeLayout: Emitter<NotebookDiffLayoutChangedEvent>;
23
- readonly onDidChangeLayout: import("../../../../../base/common/event.js").Event<NotebookDiffLayoutChangedEvent>;
24
- protected readonly _onDidChangeCellLayout: Emitter<NotebookCellLayoutChangedEvent>;
25
- readonly onDidChangeCellLayout: import("../../../../../base/common/event.js").Event<NotebookCellLayoutChangedEvent>;
26
- emit(events: NotebookDiffViewEvent[]): void;
27
- }
@@ -1,40 +0,0 @@
1
-
2
- import { Emitter } from '../../../../../base/common/event.js';
3
- import { Disposable } from '../../../../../base/common/lifecycle.js';
4
-
5
- var NotebookDiffViewEventType;
6
- (function(NotebookDiffViewEventType) {
7
- NotebookDiffViewEventType[NotebookDiffViewEventType["LayoutChanged"] = 1] = "LayoutChanged";
8
- NotebookDiffViewEventType[NotebookDiffViewEventType["CellLayoutChanged"] = 2] = "CellLayoutChanged";
9
- })(NotebookDiffViewEventType || (NotebookDiffViewEventType = {}));
10
- class NotebookDiffLayoutChangedEvent {
11
- constructor(source, value) {
12
- this.source = source;
13
- this.value = value;
14
- this.type = NotebookDiffViewEventType.LayoutChanged;
15
- }
16
- }
17
- class NotebookDiffEditorEventDispatcher extends Disposable {
18
- constructor() {
19
- super(...arguments);
20
- this._onDidChangeLayout = this._register(( new Emitter()));
21
- this.onDidChangeLayout = this._onDidChangeLayout.event;
22
- this._onDidChangeCellLayout = this._register(( new Emitter()));
23
- this.onDidChangeCellLayout = this._onDidChangeCellLayout.event;
24
- }
25
- emit(events) {
26
- for (let i = 0, len = events.length; i < len; i++) {
27
- const e = events[i];
28
- switch (e.type) {
29
- case NotebookDiffViewEventType.LayoutChanged:
30
- this._onDidChangeLayout.fire(e);
31
- break;
32
- case NotebookDiffViewEventType.CellLayoutChanged:
33
- this._onDidChangeCellLayout.fire(e);
34
- break;
35
- }
36
- }
37
- }
38
- }
39
-
40
- export { NotebookDiffEditorEventDispatcher, NotebookDiffLayoutChangedEvent, NotebookDiffViewEventType };
@@ -1,23 +0,0 @@
1
- import { DisposableStore } from "../../../../../../base/common/lifecycle.js";
2
- import { INotebookEditor } from "../../notebookBrowser.js";
3
- import { ICodeEditor } from "../../../../../../editor/browser/editorBrowser.js";
4
- import { IEditorWorkerService } from "../../../../../../editor/common/services/editorWorker.service.js";
5
- import { NotebookCellTextModel } from "../../../common/model/notebookCellTextModel.js";
6
- import { INotebookOriginalCellModelFactory } from "./notebookOriginalCellModelFactory.service.js";
7
- export declare class NotebookCellDiffDecorator extends DisposableStore {
8
- readonly modifiedCell: NotebookCellTextModel;
9
- readonly originalCell: NotebookCellTextModel;
10
- private readonly editor;
11
- private readonly _editorWorkerService;
12
- private readonly originalCellModelFactory;
13
- private _viewZones;
14
- private readonly throttledDecorator;
15
- private diffForPreviouslyAppliedDecorators?;
16
- private readonly perEditorDisposables;
17
- constructor(notebookEditor: INotebookEditor, modifiedCell: NotebookCellTextModel, originalCell: NotebookCellTextModel, editor: ICodeEditor, _editorWorkerService: IEditorWorkerService, originalCellModelFactory: INotebookOriginalCellModelFactory);
18
- update(editor: ICodeEditor): void;
19
- private _updateImpl;
20
- private _originalModel?;
21
- private getOrCreateOriginalModel;
22
- private _updateWithDiff;
23
- }
@@ -1,313 +0,0 @@
1
-
2
- import { __decorate, __param } from '../../../../../../../../../external/tslib/tslib.es6.js';
3
- import { DisposableStore, toDisposable } from '../../../../../../base/common/lifecycle.js';
4
- import '../../../../../../base/common/observableInternal/index.js';
5
- import { ThrottledDelayer } from '../../../../../../base/common/async.js';
6
- import { IEditorWorkerService } from '../../../../../../editor/common/services/editorWorker.service.js';
7
- import { EditorOption } from '../../../../../../editor/common/config/editorOptions.js';
8
- import { themeColorFromId } from '../../../../../../base/common/themables.js';
9
- import { RenderOptions, LineSource, renderLines } from '../../../../../../editor/browser/widget/diffEditor/components/diffEditorViewZones/renderLines.js';
10
- import { diffAddDecoration, diffWholeLineAddDecoration, diffDeleteDecoration } from '../../../../../../editor/browser/widget/diffEditor/registrations.contribution.js';
11
- import { TrackedRangeStickiness, MinimapPosition, OverviewRulerLane } from '../../../../../../editor/common/model.js';
12
- import { ModelDecorationOptions } from '../../../../../../editor/common/model/textModel.js';
13
- import { Range } from '../../../../../../editor/common/core/range.js';
14
- import { overviewRulerModifiedForeground, minimapGutterModifiedBackground, overviewRulerAddedForeground, minimapGutterAddedBackground, overviewRulerDeletedForeground, minimapGutterDeletedBackground } from '../../../../scm/common/quickDiff.js';
15
- import { INotebookOriginalCellModelFactory } from './notebookOriginalCellModelFactory.service.js';
16
- import { InlineDecoration, InlineDecorationType } from '../../../../../../editor/common/viewModel/inlineDecorations.js';
17
- import { createElement } from '../../../../../../base/browser/dom.js';
18
- import { observableFromEvent } from '../../../../../../base/common/observableInternal/observables/observableFromEvent.js';
19
- import { derived } from '../../../../../../base/common/observableInternal/observables/derived.js';
20
- import { autorunWithStore } from '../../../../../../base/common/observableInternal/reactions/autorun.js';
21
-
22
- let NotebookCellDiffDecorator = class NotebookCellDiffDecorator extends DisposableStore {
23
- constructor(
24
- notebookEditor,
25
- modifiedCell,
26
- originalCell,
27
- editor,
28
- _editorWorkerService,
29
- originalCellModelFactory
30
- ) {
31
- super();
32
- this.modifiedCell = modifiedCell;
33
- this.originalCell = originalCell;
34
- this.editor = editor;
35
- this._editorWorkerService = _editorWorkerService;
36
- this.originalCellModelFactory = originalCellModelFactory;
37
- this._viewZones = [];
38
- this.throttledDecorator = this.add(( new ThrottledDelayer(50)));
39
- this.perEditorDisposables = this.add(( new DisposableStore()));
40
- const onDidChangeVisibleRanges = observableFromEvent(
41
- notebookEditor.onDidChangeVisibleRanges,
42
- () => notebookEditor.visibleRanges
43
- );
44
- const editorObs = derived(r => {
45
- const visibleRanges = onDidChangeVisibleRanges.read(r);
46
- const visibleCellHandles = ( ( visibleRanges.map(range => notebookEditor.getCellsInRange(range))).flat().map(c => c.handle));
47
- if (!visibleCellHandles.includes(modifiedCell.handle)) {
48
- return;
49
- }
50
- const editor = notebookEditor.codeEditors.find(item => item[0].handle === modifiedCell.handle)?.[1];
51
- if (editor?.getModel() !== this.modifiedCell.textModel) {
52
- return;
53
- }
54
- return editor;
55
- });
56
- this.add(autorunWithStore((r, store) => {
57
- const editor = editorObs.read(r);
58
- this.perEditorDisposables.clear();
59
- if (editor) {
60
- store.add(editor.onDidChangeModel(() => {
61
- this.perEditorDisposables.clear();
62
- }));
63
- store.add(editor.onDidChangeModelContent(() => {
64
- this.update(editor);
65
- }));
66
- store.add(editor.onDidChangeConfiguration(e => {
67
- if (e.hasChanged(EditorOption.fontInfo) || e.hasChanged(EditorOption.lineHeight)) {
68
- this.update(editor);
69
- }
70
- }));
71
- this.update(editor);
72
- }
73
- }));
74
- }
75
- update(editor) {
76
- this.throttledDecorator.trigger(() => this._updateImpl(editor));
77
- }
78
- async _updateImpl(editor) {
79
- if (this.isDisposed) {
80
- return;
81
- }
82
- if (editor.getOption(EditorOption.inDiffEditor)) {
83
- this.perEditorDisposables.clear();
84
- return;
85
- }
86
- const model = editor.getModel();
87
- if (!model || model !== this.modifiedCell.textModel) {
88
- this.perEditorDisposables.clear();
89
- return;
90
- }
91
- const originalModel = this.getOrCreateOriginalModel(editor);
92
- if (!originalModel) {
93
- this.perEditorDisposables.clear();
94
- return;
95
- }
96
- const version = model.getVersionId();
97
- const diff = await this._editorWorkerService.computeDiff(originalModel.uri, model.uri, {
98
- computeMoves: true,
99
- ignoreTrimWhitespace: false,
100
- maxComputationTimeMs: Number.MAX_SAFE_INTEGER
101
- }, "advanced");
102
- if (this.isDisposed) {
103
- return;
104
- }
105
- if (diff && !diff.identical && this.modifiedCell.textModel && originalModel && model === editor.getModel() && editor.getModel()?.getVersionId() === version) {
106
- this._updateWithDiff(editor, originalModel, diff, this.modifiedCell.textModel);
107
- } else {
108
- this.perEditorDisposables.clear();
109
- }
110
- }
111
- getOrCreateOriginalModel(editor) {
112
- if (!this._originalModel) {
113
- const model = editor.getModel();
114
- if (!model) {
115
- return;
116
- }
117
- this._originalModel = this.add(this.originalCellModelFactory.getOrCreate(
118
- model.uri,
119
- this.originalCell.getValue(),
120
- model.getLanguageId(),
121
- this.modifiedCell.cellKind
122
- )).object;
123
- }
124
- return this._originalModel;
125
- }
126
- _updateWithDiff(editor, originalModel, diff, currentModel) {
127
- if (areDiffsEqual(diff, this.diffForPreviouslyAppliedDecorators)) {
128
- return;
129
- }
130
- this.perEditorDisposables.clear();
131
- const decorations = editor.createDecorationsCollection();
132
- this.perEditorDisposables.add(toDisposable(() => {
133
- editor.changeViewZones(viewZoneChangeAccessor => {
134
- for (const id of this._viewZones) {
135
- viewZoneChangeAccessor.removeZone(id);
136
- }
137
- });
138
- this._viewZones = [];
139
- decorations.clear();
140
- this.diffForPreviouslyAppliedDecorators = undefined;
141
- }));
142
- this.diffForPreviouslyAppliedDecorators = diff;
143
- const chatDiffAddDecoration = ModelDecorationOptions.createDynamic({
144
- ...diffAddDecoration,
145
- stickiness: TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges
146
- });
147
- const chatDiffWholeLineAddDecoration = ModelDecorationOptions.createDynamic({
148
- ...diffWholeLineAddDecoration,
149
- stickiness: TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges
150
- });
151
- const createOverviewDecoration = (overviewRulerColor, minimapColor) => {
152
- return ModelDecorationOptions.createDynamic({
153
- description: "chat-editing-decoration",
154
- overviewRuler: {
155
- color: themeColorFromId(overviewRulerColor),
156
- position: OverviewRulerLane.Left
157
- },
158
- minimap: {
159
- color: themeColorFromId(minimapColor),
160
- position: MinimapPosition.Gutter
161
- }
162
- });
163
- };
164
- const modifiedDecoration = createOverviewDecoration(overviewRulerModifiedForeground, minimapGutterModifiedBackground);
165
- const addedDecoration = createOverviewDecoration(overviewRulerAddedForeground, minimapGutterAddedBackground);
166
- const deletedDecoration = createOverviewDecoration(overviewRulerDeletedForeground, minimapGutterDeletedBackground);
167
- editor.changeViewZones(viewZoneChangeAccessor => {
168
- for (const id of this._viewZones) {
169
- viewZoneChangeAccessor.removeZone(id);
170
- }
171
- this._viewZones = [];
172
- const modifiedVisualDecorations = [];
173
- const mightContainNonBasicASCII = originalModel.mightContainNonBasicASCII();
174
- const mightContainRTL = originalModel.mightContainRTL();
175
- const renderOptions = RenderOptions.fromEditor(this.editor);
176
- const editorLineCount = currentModel.getLineCount();
177
- for (const diffEntry of diff.changes) {
178
- const originalRange = diffEntry.original;
179
- originalModel.tokenization.forceTokenization(Math.max(1, originalRange.endLineNumberExclusive - 1));
180
- const source = ( new LineSource(
181
- originalRange.mapToLineArray(l => originalModel.tokenization.getLineTokens(l)),
182
- [],
183
- mightContainNonBasicASCII,
184
- mightContainRTL
185
- ));
186
- const decorations = [];
187
- for (const i of diffEntry.innerChanges || []) {
188
- decorations.push(( new InlineDecoration(
189
- i.originalRange.delta(-(diffEntry.original.startLineNumber - 1)),
190
- diffDeleteDecoration.className,
191
- InlineDecorationType.Regular
192
- )));
193
- if (!(i.originalRange.isEmpty() && i.originalRange.startLineNumber === 1 && i.modifiedRange.endLineNumber === editorLineCount) && !i.modifiedRange.isEmpty()) {
194
- modifiedVisualDecorations.push({
195
- range: i.modifiedRange,
196
- options: chatDiffAddDecoration
197
- });
198
- }
199
- }
200
- const isCreatedContent = decorations.length === 1 && decorations[0].range.isEmpty() && diffEntry.original.startLineNumber === 1;
201
- if (!diffEntry.modified.isEmpty && !(isCreatedContent && (diffEntry.modified.endLineNumberExclusive - 1) === editorLineCount)) {
202
- modifiedVisualDecorations.push({
203
- range: diffEntry.modified.toInclusiveRange(),
204
- options: chatDiffWholeLineAddDecoration
205
- });
206
- }
207
- if (diffEntry.original.isEmpty) {
208
- modifiedVisualDecorations.push({
209
- range: diffEntry.modified.toInclusiveRange(),
210
- options: addedDecoration
211
- });
212
- } else if (diffEntry.modified.isEmpty) {
213
- modifiedVisualDecorations.push({
214
- range: ( new Range(
215
- diffEntry.modified.startLineNumber - 1,
216
- 1,
217
- diffEntry.modified.startLineNumber,
218
- 1
219
- )),
220
- options: deletedDecoration
221
- });
222
- } else {
223
- modifiedVisualDecorations.push({
224
- range: diffEntry.modified.toInclusiveRange(),
225
- options: modifiedDecoration
226
- });
227
- }
228
- const domNode = createElement("div");
229
- domNode.className = "chat-editing-original-zone view-lines line-delete monaco-mouse-cursor-text";
230
- const result = renderLines(source, renderOptions, decorations, domNode);
231
- if (!isCreatedContent) {
232
- const viewZoneData = {
233
- afterLineNumber: diffEntry.modified.startLineNumber - 1,
234
- heightInLines: result.heightInLines,
235
- domNode,
236
- ordinal: 50000 + 2
237
- };
238
- this._viewZones.push(viewZoneChangeAccessor.addZone(viewZoneData));
239
- }
240
- }
241
- decorations.set(modifiedVisualDecorations);
242
- });
243
- }
244
- };
245
- NotebookCellDiffDecorator = ( __decorate([( __param(4, IEditorWorkerService)), ( __param(5, INotebookOriginalCellModelFactory))], NotebookCellDiffDecorator));
246
- function areDiffsEqual(a, b) {
247
- if (a && b) {
248
- if (a.changes.length !== b.changes.length) {
249
- return false;
250
- }
251
- if (a.moves.length !== b.moves.length) {
252
- return false;
253
- }
254
- if (!areLineRangeMappinsEqual(a.changes, b.changes)) {
255
- return false;
256
- }
257
- if (!( a.moves.some((move, i) => {
258
- const bMove = b.moves[i];
259
- if (!areLineRangeMappinsEqual(move.changes, bMove.changes)) {
260
- return true;
261
- }
262
- if (move.lineRangeMapping.changedLineCount !== bMove.lineRangeMapping.changedLineCount) {
263
- return true;
264
- }
265
- if (!move.lineRangeMapping.modified.equals(bMove.lineRangeMapping.modified)) {
266
- return true;
267
- }
268
- if (!move.lineRangeMapping.original.equals(bMove.lineRangeMapping.original)) {
269
- return true;
270
- }
271
- return false;
272
- }))) {
273
- return false;
274
- }
275
- return true;
276
- } else if (!a && !b) {
277
- return true;
278
- } else {
279
- return false;
280
- }
281
- }
282
- function areLineRangeMappinsEqual(a, b) {
283
- if (a.length !== b.length) {
284
- return false;
285
- }
286
- if (( a.some((c, i) => {
287
- const bChange = b[i];
288
- if (c.changedLineCount !== bChange.changedLineCount) {
289
- return true;
290
- }
291
- if ((c.innerChanges || []).length !== (bChange.innerChanges || []).length) {
292
- return true;
293
- }
294
- if (( (c.innerChanges || []).some((innerC, innerIdx) => {
295
- const bInnerC = bChange.innerChanges[innerIdx];
296
- if (!innerC.modifiedRange.equalsRange(bInnerC.modifiedRange)) {
297
- return true;
298
- }
299
- if (!innerC.originalRange.equalsRange(bInnerC.originalRange)) {
300
- return true;
301
- }
302
- return false;
303
- }))) {
304
- return true;
305
- }
306
- return false;
307
- }))) {
308
- return false;
309
- }
310
- return true;
311
- }
312
-
313
- export { NotebookCellDiffDecorator };