Skip to content

Commit 88a7d66

Browse files
committed
build text diff editor
1 parent 509bc25 commit 88a7d66

7 files changed

Lines changed: 904 additions & 14 deletions

File tree

src/vs/editor/browser/widget/diffEditorWidget.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,9 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
175175
private readonly _onDidUpdateDiff: Emitter<void> = this._register(new Emitter<void>());
176176
public readonly onDidUpdateDiff: Event<void> = this._onDidUpdateDiff.event;
177177

178+
private readonly _onDidContentSizeChange: Emitter<editorCommon.IContentSizeChangedEvent> = this._register(new Emitter<editorCommon.IContentSizeChangedEvent>());
179+
public readonly onDidContentSizeChange: Event<editorCommon.IContentSizeChangedEvent> = this._onDidContentSizeChange.event;
180+
178181
private readonly id: number;
179182
private _state: editorBrowser.DiffEditorState;
180183
private _updatingDiffProgress: IProgressRunner | null;
@@ -421,6 +424,10 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
421424
return this._renderIndicators;
422425
}
423426

427+
public getContentHeight(): number {
428+
return this.modifiedEditor.getContentHeight();
429+
}
430+
424431
private _setState(newState: editorBrowser.DiffEditorState): void {
425432
if (this._state === newState) {
426433
return;
@@ -555,6 +562,18 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
555562
}
556563
}));
557564

565+
this._register(editor.onDidContentSizeChange(e => {
566+
const width = this.originalEditor.getContentWidth() + this.modifiedEditor.getContentWidth();
567+
const height = this.modifiedEditor.getContentHeight();
568+
569+
this._onDidContentSizeChange.fire({
570+
contentHeight: height,
571+
contentWidth: width,
572+
contentHeightChanged: e.contentHeightChanged,
573+
contentWidthChanged: e.contentWidthChanged
574+
});
575+
}));
576+
558577
return editor;
559578
}
560579

src/vs/workbench/contrib/notebook/browser/media/notebookDiff.css renamed to src/vs/workbench/contrib/notebook/browser/diff/celllDiffViewModel.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,13 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
.notebook-diff-editor {
7-
display: flex;
8-
flex-direction: row;
9-
height: 100%;
10-
width: 100%;
11-
}
12-
.notebook-diff-editor-modified,
13-
.notebook-diff-editor-original {
14-
display: flex;
15-
height: 100%;
16-
width: 50%;
6+
import { NotebookCellTextModel } from 'vs/workbench/contrib/notebook/common/model/notebookCellTextModel';
7+
8+
export class CellDiffViewModel {
9+
constructor(
10+
readonly original: NotebookCellTextModel | undefined,
11+
readonly modified: NotebookCellTextModel | undefined,
12+
readonly type: 'unchanged' | 'insert' | 'delete' | 'modified'
13+
) {
14+
}
1715
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
import { NotebookLayoutInfo } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
7+
import { CellDiffViewModel } from 'vs/workbench/contrib/notebook/browser/diff/celllDiffViewModel';
8+
9+
export interface INotebookTextDiffEditor {
10+
getLayoutInfo(): NotebookLayoutInfo;
11+
layoutNotebookCell(cell: CellDiffViewModel, height: number): void;
12+
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
/* .notebook-diff-editor {
7+
display: flex;
8+
flex-direction: row;
9+
height: 100%;
10+
width: 100%;
11+
}
12+
.notebook-diff-editor-modified,
13+
.notebook-diff-editor-original {
14+
display: flex;
15+
height: 100%;
16+
width: 50%;
17+
} */
18+
19+
.notebook-text-diff-editor .cell-diff-editor-container {
20+
margin: 8px;
21+
}
22+
23+
.notebook-text-diff-editor .cell-diff-editor-container .metadata-container {
24+
display: flex;
25+
height: 24px;
26+
align-items: center;
27+
cursor: default;
28+
}
29+
30+
.notebook-text-diff-editor .cell-diff-editor-container .metadata-container .metadata-folding-indicator .codicon {
31+
visibility: visible;
32+
padding: 4px 0 0 10px;
33+
cursor: pointer;
34+
}
35+
36+
.notebook-text-diff-editor .cell-diff-editor-container .metadata-container .metadata-status {
37+
font-size: 12px;
38+
}
39+
40+
.notebook-text-diff-editor .cell-diff-editor-container .metadata-container .metadata-status span {
41+
margin: 0 8px;
42+
line-height: 21px;
43+
}
44+
45+
.notebook-text-diff-editor .cell-diff-editor-container.delete .editor-container {
46+
display: inline-block;
47+
width: calc(50% - 18px);
48+
}
49+
50+
.notebook-text-diff-editor .cell-diff-editor-container.delete .diagonal-fill {
51+
display: inline-block;
52+
width: calc(50% + 18px);
53+
}
54+
55+
.notebook-text-diff-editor .cell-diff-editor-container.insert .editor-container {
56+
display: inline-block;
57+
width: calc(50% + 18px);
58+
}
59+
60+
.notebook-text-diff-editor .cell-diff-editor-container.insert .diagonal-fill {
61+
display: inline-block;
62+
width: calc(50% - 18px);
63+
}
64+
65+
.notebook-text-diff-editor {
66+
overflow: hidden;
67+
}
68+
69+
.monaco-workbench .notebook-text-diff-editor > .monaco-list > .monaco-scrollable-element > .monaco-list-rows > .monaco-list-row,
70+
.monaco-workbench .notebook-text-diff-editor > .monaco-list > .monaco-scrollable-element > .monaco-list-rows > .monaco-list-row:hover,
71+
.monaco-workbench .notebook-text-diff-editor > .monaco-list > .monaco-scrollable-element > .monaco-list-rows > .monaco-list-row.focused {
72+
outline: none !important;
73+
}

0 commit comments

Comments
 (0)