Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes checkbox layout bug. #158013

Merged
merged 1 commit into from Aug 12, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -374,10 +374,27 @@ export class MergeConflictGutterItemView extends Disposable implements IGutterIt
const margin = checkboxHeight;

const effectiveCheckboxTop = top + middleHeight;
const clamped1 = clamp(effectiveCheckboxTop, margin, viewTop + viewHeight - margin - checkboxHeight);
const clamped2 = clamp(clamped1, top + margin, top + height - checkboxHeight - margin);

this.checkboxDiv.style.top = `${clamped2 - top}px`;
const preferredViewPortRange = [
margin,
viewTop + viewHeight - margin - checkboxHeight
];

const preferredParentRange = [
top + margin,
top + height - checkboxHeight - margin
];

const parentRange = [
top,
top + height - checkboxHeight
];

const clamped1 = clampIfIntervalIsNonEmpty(effectiveCheckboxTop, preferredViewPortRange[0], preferredViewPortRange[1]);
const clamped2 = clampIfIntervalIsNonEmpty(clamped1, preferredParentRange[0], preferredParentRange[1]);
const clamped3 = clamp(clamped2, parentRange[0], parentRange[1]);

this.checkboxDiv.style.top = `${clamped3 - top}px`;

this.target.classList.remove('multi-line');
this.target.classList.remove('single-line');
Expand All @@ -391,3 +408,10 @@ export class MergeConflictGutterItemView extends Disposable implements IGutterIt
});
}
}

function clampIfIntervalIsNonEmpty(value: number, min: number, max: number): number {
if (min >= max) {
return value;
}
return Math.min(Math.max(value, min), max);
}