Skip to content

Commit dc5fe33

Browse files
authored
Diff Editor v2: Improves collapse unchanged code feature (microsoft#185226)
* Diff Editor v2: Improves collapse unchanged code feature * Updates Labels
1 parent d7eb1e4 commit dc5fe33

File tree

5 files changed

+44
-21
lines changed

5 files changed

+44
-21
lines changed

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

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -143,17 +143,19 @@ export class DiffEditorWidget2 extends DelegatingEditor implements IDiffEditor {
143143
});
144144
this._register(keepAlive(this._sash, true));
145145

146-
this._register(new UnchangedRangesFeature(this._originalEditor, this._modifiedEditor, this._diffModel));
147-
this._register(
148-
this._instantiationService.createInstance(
149-
ViewZoneManager,
150-
this._originalEditor,
151-
this._modifiedEditor,
152-
this._diffModel,
153-
this._options.map((o) => o.renderSideBySide),
154-
this
155-
)
156-
);
146+
this._register(new UnchangedRangesFeature(
147+
this._originalEditor,
148+
this._modifiedEditor,
149+
this._diffModel
150+
));
151+
this._register(this._instantiationService.createInstance(
152+
ViewZoneManager,
153+
this._originalEditor,
154+
this._modifiedEditor,
155+
this._diffModel,
156+
this._options.map((o) => o.renderSideBySide),
157+
this,
158+
));
157159

158160
this._register(this._instantiationService.createInstance(OverviewRulerPart,
159161
this._originalEditor,
Lines changed: 4 additions & 2 deletions
Loading
Lines changed: 4 additions & 2 deletions
Loading

src/vs/editor/browser/widget/diffEditorWidget2/style.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
display: block;
2929
text-overflow: ellipsis;
3030
white-space: nowrap;
31+
32+
height: 20px;
3133
}
3234

3335
.diff-hidden-lines .center > span,

src/vs/editor/browser/widget/diffEditorWidget2/unchangedRanges.ts

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,26 +74,38 @@ export class UnchangedRangesFeature extends Disposable {
7474
if (hiddenOriginalRange.isEmpty) {
7575
continue;
7676
}
77+
const marginDomNode1 = h('div.diff-hidden-lines', { className: [true ? 'showTop' : '', true ? 'showBottom' : ''].join(' ') }, [
78+
h('div.top'),
79+
h('div.center@content'),
80+
h('div.bottom'),
81+
]).root;
7782

7883
store.add(new CollapsedCodeActionsContentWidget(this._originalEditor, aOrig, hiddenOriginalRange.startLineNumber - 1, 30, constObservable<IContentWidgetAction[]>([
7984
{
8085
text: `${hiddenOriginalRange.length} Lines Hidden`
8186
},
8287
{
83-
text: '$(chevron-up) Show More',
88+
text: '$(chevron-up) Show More Above',
8489
async action() { r.showMoreAbove(undefined); },
8590
},
8691
{
87-
text: '$(chevron-down) Show More',
92+
text: '$(chevron-down) Show More Below',
8893
async action() { r.showMoreBelow(undefined); },
8994
},
9095
{
9196
text: '$(close) Show All',
9297
async action() { r.showAll(undefined); },
9398
}
94-
]), unchangedRegionViewZoneIdsOrig, atTop, atBottom));
99+
]), unchangedRegionViewZoneIdsOrig, atTop, atBottom, marginDomNode1));
100+
101+
const marginDomNode = h('div.diff-hidden-lines', { className: [true ? 'showTop' : '', true ? 'showBottom' : ''].join(' ') }, [
102+
h('div.top'),
103+
h('div.center@content'),
104+
h('div.bottom'),
105+
]).root;
95106

96107
store.add(new CollapsedCodeActionsContentWidget(this._modifiedEditor, aMod, hiddenModifiedRange.startLineNumber - 1, 30, constObservable<IContentWidgetAction[]>([
108+
/* Dont show buttons for modified, but maybe revisit that
97109
{
98110
text: '$(chevron-up) Show More',
99111
async action() { r.showMoreAbove(undefined); },
@@ -106,15 +118,15 @@ export class UnchangedRangesFeature extends Disposable {
106118
text: '$(close) Show All',
107119
async action() { r.showAll(undefined); },
108120
}
109-
]), unchangedRegionViewZoneIdsMod, atTop, atBottom));
121+
*/
122+
]), unchangedRegionViewZoneIdsMod, atTop, atBottom, marginDomNode));
110123
}
111124
});
112125
});
113126

114127
this._originalEditor.setHiddenAreas(unchangedRegions.map(r => r.getHiddenOriginalRange(reader).toInclusiveRange()).filter(isDefined));
115128
this._modifiedEditor.setHiddenAreas(unchangedRegions.map(r => r.getHiddenModifiedRange(reader).toInclusiveRange()).filter(isDefined));
116129
}));
117-
118130
}
119131
}
120132

@@ -137,6 +149,7 @@ abstract class FixedZoneWidget extends Disposable {
137149
afterLineNumber: number,
138150
height: number,
139151
viewZoneIdsToCleanUp: string[],
152+
marginDomNode: HTMLElement | undefined,
140153
) {
141154
super();
142155

@@ -151,6 +164,7 @@ abstract class FixedZoneWidget extends Disposable {
151164
this.widgetDomNode.style.top = `${top}px`;
152165
},
153166
showInHiddenAreas: true,
167+
marginDomNode,
154168
});
155169
viewZoneIdsToCleanUp.push(this.viewZoneId);
156170

@@ -183,8 +197,9 @@ class CollapsedCodeActionsContentWidget extends FixedZoneWidget {
183197
viewZoneIdsToCleanUp: string[],
184198
public readonly showTopZigZag: boolean,
185199
public readonly showBottomZigZag: boolean,
200+
marginDomNode: HTMLElement | undefined,
186201
) {
187-
super(editor, viewZoneAccessor, afterLineNumber, height, viewZoneIdsToCleanUp);
202+
super(editor, viewZoneAccessor, afterLineNumber, height, viewZoneIdsToCleanUp, marginDomNode);
188203

189204
this.widgetDomNode.appendChild(this._domNode.root);
190205

0 commit comments

Comments
 (0)