Skip to content

Commit d434e27

Browse files
committed
1 parent bf0c6eb commit d434e27

File tree

3 files changed

+48
-6
lines changed

3 files changed

+48
-6
lines changed

src/vs/editor/browser/widget/diffEditor/diffEditorViewModel.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ export class UnchangedRegion {
418418
private readonly _shouldHideControls = derived(this, reader => /** @description isVisible */
419419
this.visibleLineCountTop.read(reader) + this.visibleLineCountBottom.read(reader) === this.lineCount && !this.isDragged.read(reader));
420420

421-
public readonly isDragged = observableValue<boolean>(this, false);
421+
public readonly isDragged = observableValue<undefined | 'bottom' | 'top'>(this, undefined);
422422

423423
constructor(
424424
public readonly originalLineNumber: number,

src/vs/editor/browser/widget/diffEditor/hideUnchangedRegionsFeature.ts

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,30 @@ class CollapsedCodeOverlayWidget extends ViewZoneOverlayWidget {
258258
reset(this._nodes.first);
259259
}
260260

261+
this._register(autorun(reader => {
262+
const isFullyRevealed = this._unchangedRegion.visibleLineCountTop.read(reader) + this._unchangedRegion.visibleLineCountBottom.read(reader) === this._unchangedRegion.lineCount;
263+
264+
this._nodes.bottom.classList.toggle('canMoveTop', !isFullyRevealed);
265+
this._nodes.bottom.classList.toggle('canMoveBottom', this._unchangedRegion.visibleLineCountBottom.read(reader) > 0);
266+
this._nodes.top.classList.toggle('canMoveTop', this._unchangedRegion.visibleLineCountTop.read(reader) > 0);
267+
this._nodes.top.classList.toggle('canMoveBottom', !isFullyRevealed);
268+
const isDragged = this._unchangedRegion.isDragged.read(reader);
269+
const domNode = this._editor.getDomNode();
270+
if (domNode) {
271+
domNode.classList.toggle('draggingUnchangedRegion', !!isDragged);
272+
if (isDragged === 'top') {
273+
domNode.classList.toggle('canMoveTop', this._unchangedRegion.visibleLineCountTop.read(reader) > 0);
274+
domNode.classList.toggle('canMoveBottom', !isFullyRevealed);
275+
} else if (isDragged === 'bottom') {
276+
domNode.classList.toggle('canMoveTop', !isFullyRevealed);
277+
domNode.classList.toggle('canMoveBottom', this._unchangedRegion.visibleLineCountBottom.read(reader) > 0);
278+
} else {
279+
domNode.classList.toggle('canMoveTop', false);
280+
domNode.classList.toggle('canMoveBottom', false);
281+
}
282+
}
283+
}));
284+
261285
const editor = this._editor;
262286

263287
this._register(addDisposableListener(this._nodes.top, 'mousedown', e => {
@@ -270,7 +294,7 @@ class CollapsedCodeOverlayWidget extends ViewZoneOverlayWidget {
270294
const startTop = e.clientY;
271295
let didMove = false;
272296
const cur = this._unchangedRegion.visibleLineCountTop.get();
273-
this._unchangedRegion.isDragged.set(true, undefined);
297+
this._unchangedRegion.isDragged.set('top', undefined);
274298

275299
const window = getWindow(this._nodes.top);
276300

@@ -289,7 +313,7 @@ class CollapsedCodeOverlayWidget extends ViewZoneOverlayWidget {
289313
}
290314
this._nodes.top.classList.toggle('dragging', false);
291315
this._nodes.root.classList.toggle('dragging', false);
292-
this._unchangedRegion.isDragged.set(false, undefined);
316+
this._unchangedRegion.isDragged.set(undefined, undefined);
293317
mouseMoveListener.dispose();
294318
mouseUpListener.dispose();
295319
});
@@ -305,7 +329,7 @@ class CollapsedCodeOverlayWidget extends ViewZoneOverlayWidget {
305329
const startTop = e.clientY;
306330
let didMove = false;
307331
const cur = this._unchangedRegion.visibleLineCountBottom.get();
308-
this._unchangedRegion.isDragged.set(true, undefined);
332+
this._unchangedRegion.isDragged.set('bottom', undefined);
309333

310334
const window = getWindow(this._nodes.bottom);
311335

@@ -322,7 +346,7 @@ class CollapsedCodeOverlayWidget extends ViewZoneOverlayWidget {
322346
});
323347

324348
const mouseUpListener = addDisposableListener(window, 'mouseup', e => {
325-
this._unchangedRegion.isDragged.set(false, undefined);
349+
this._unchangedRegion.isDragged.set(undefined, undefined);
326350

327351
if (!didMove) {
328352
const top = editor.getTopForLineNumber(this._unchangedRegionRange.endLineNumberExclusive);

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

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,25 @@
2929
background-clip: padding-box;
3030
border-bottom: 2px solid transparent;
3131
border-top: 4px solid transparent;
32-
cursor: ns-resize;
32+
/*cursor: n-resize;*/
33+
}
34+
35+
.monaco-editor.draggingUnchangedRegion.canMoveTop:not(.canMoveBottom) *,
36+
.monaco-editor .diff-hidden-lines .top.canMoveTop:not(.canMoveBottom),
37+
.monaco-editor .diff-hidden-lines .bottom.canMoveTop:not(.canMoveBottom) {
38+
cursor: n-resize !important;
39+
}
40+
41+
.monaco-editor.draggingUnchangedRegion:not(.canMoveTop).canMoveBottom *,
42+
.monaco-editor .diff-hidden-lines .top:not(.canMoveTop).canMoveBottom,
43+
.monaco-editor .diff-hidden-lines .bottom:not(.canMoveTop).canMoveBottom {
44+
cursor: s-resize !important;
45+
}
46+
47+
.monaco-editor.draggingUnchangedRegion.canMoveTop.canMoveBottom *,
48+
.monaco-editor .diff-hidden-lines .top.canMoveTop.canMoveBottom,
49+
.monaco-editor .diff-hidden-lines .bottom.canMoveTop.canMoveBottom {
50+
cursor: ns-resize !important;
3351
}
3452

3553
.monaco-editor .diff-hidden-lines .top {

0 commit comments

Comments
 (0)