Skip to content

Commit 6d3f7ad

Browse files
committed
Remove extra vertical margins around selection rectangles
FIX: Make selection rectangles verticaly align precisely, rather than introducing a slight overlap. See https://discuss.codemirror.net/t/issue-with-selection-highlight-overlapping/8882
1 parent 6e6b285 commit 6d3f7ad

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

src/layer.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,6 @@ function wrappedLine(view: EditorView, pos: number, side: 1 | -1, inside: {from:
9898
return {from: Math.max(inside.from, Math.min(left, right)), to: Math.min(inside.to, Math.max(left, right))}
9999
}
100100

101-
// Added to range rectangle's vertical extent to prevent rounding
102-
// errors from introducing gaps in the rendered content.
103-
const enum C { Epsilon = 0.01 }
104-
105101
function rectanglesForRange(view: EditorView, className: string, range: SelectionRange): RectangleMarker[] {
106102
if (range.to <= view.viewport.from || range.from >= view.viewport.to) return []
107103
let from = Math.max(range.from, view.viewport.from), to = Math.min(range.to, view.viewport.to)
@@ -135,8 +131,8 @@ function rectanglesForRange(view: EditorView, className: string, range: Selectio
135131
}
136132

137133
function piece(left: number, top: number, right: number, bottom: number) {
138-
return new RectangleMarker(className, left - base.left, top - base.top - C.Epsilon,
139-
right - left, bottom - top + C.Epsilon)
134+
return new RectangleMarker(className, left - base.left, top - base.top,
135+
right - left, bottom - top)
140136
}
141137
function pieces({top, bottom, horizontal}: {top: number, bottom: number, horizontal: number[]}) {
142138
let pieces = []

0 commit comments

Comments
 (0)