Skip to content

Commit 72b13a7

Browse files
committed
Avoid unneeded focusing of the SimpleEditor
1 parent 5493819 commit 72b13a7

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

ui/frontend/editor/SimpleEditor.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React from 'react';
2+
import { isEqual } from 'lodash';
23

34
import { CommonEditorProps, Position, Selection } from '../types';
45

@@ -80,7 +81,7 @@ class SimpleEditor extends React.PureComponent<CommonEditorProps> {
8081
const editor = this._editor;
8182

8283
if (!newPosition || !editor) { return; }
83-
if (newPosition === oldPosition) { return; }
84+
if (isEqual(newPosition, oldPosition)) { return; }
8485

8586
const offsets = new CodeByteOffsets(this.props.code);
8687
const [startBytes, endBytes] = offsets.lineToOffsets(newPosition.line);
@@ -93,7 +94,7 @@ class SimpleEditor extends React.PureComponent<CommonEditorProps> {
9394
const editor = this._editor;
9495

9596
if (!newSelection || !newSelection.start || !newSelection.end || !editor) { return; }
96-
if (newSelection === oldSelection) { return; }
97+
if (isEqual(newSelection, oldSelection)) { return; }
9798

9899
const offsets = new CodeByteOffsets(this.props.code);
99100
const [startBytes, endBytes] = offsets.rangeToOffsets(newSelection.start, newSelection.end);

0 commit comments

Comments
 (0)