Skip to content

Commit

Permalink
Ignore tiny changes in computed scale
Browse files Browse the repository at this point in the history
FIX: Fix a bug where a scaled editor could keep performing unnecessary
updates due to tiny differences in geometry values returned by the
browser.

Closes codemirror/dev#1341
  • Loading branch information
marijnh committed Mar 8, 2024
1 parent e783cf1 commit 410ab70
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/viewstate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,8 @@ export class ViewState {

if (domRect.width && domRect.height) {
let {scaleX, scaleY} = getScale(dom, domRect)
if (this.scaleX != scaleX || this.scaleY != scaleY) {
if (scaleX > .005 && Math.abs(this.scaleX - scaleX) > .005 ||
scaleY > .005 && Math.abs(this.scaleY - scaleY) > .005) {
this.scaleX = scaleX; this.scaleY = scaleY
result |= UpdateFlag.Geometry
refresh = measureContent = true
Expand Down

0 comments on commit 410ab70

Please sign in to comment.