Skip to content

Commit 9fcabe7

Browse files
authored
Fix issues working with a scaled viewport (#374)
1 parent 9cc6a84 commit 9fcabe7

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

CoreEditor/src/styling/nodes/line.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { BlockInfo, layer, RectangleMarker } from '@codemirror/view';
22
import { EditorSelection } from '@codemirror/state';
33
import { buildInnerBorder } from '../builder';
4+
import { getViewportScale } from '../../common/utils';
45

56
const borderWidth = 2.5;
67
const rectPadding = 2.0;
@@ -63,15 +64,16 @@ class Layer extends RectangleMarker {
6364
return new DOMRect(0, 0, 0, 0);
6465
}
6566

67+
const scale = getViewportScale();
6668
const top = rects.reduce((acc, cur) => Math.min(acc, cur.top), 1e9);
6769
const height = rects.reduce((acc, cur) => acc + cur.height, 0);
6870

6971
// The rect that is slightly taller than the caret, centered vertically
7072
return new DOMRect(
71-
contentRect.left, // x
72-
top - rectPadding, // y
73-
contentRect.width, // width
74-
height + rectPadding * 2, // height
73+
contentRect.left, // x
74+
top - rectPadding, // y
75+
contentRect.width * scale, // width
76+
height + rectPadding * 2, // height
7577
);
7678
})();
7779

MarkEditMac/Sources/Editor/Controllers/EditorViewController.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ extension EditorViewController {
220220
// Toggling isHidden because line numbers are initially rendered as only "1",
221221
// it gets fixed after resetting the text, but takes time especially for huge documents.
222222
webView.isHidden = true
223+
webView.magnification = 1.0
223224

224225
bridge.core.resetEditor(text: text, revision: document?.latestRevision, readOnly: isReadOnly) { _ in
225226
self.webView.isHidden = false

0 commit comments

Comments
 (0)