Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.

Commit 2b91194

Browse files
committed
Merge pull request #8589 from MarcelGerber/inline-timing-function-batch
Batch InlineTimingFunctionEditor's changes
2 parents 0f61fcf + a224a25 commit 2b91194

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/extensions/default/InlineTimingFunctionEditor/InlineTimingFunctionEditor.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,8 @@ define(function (require, exports, module) {
156156
* @param {!string} timingFunctionString
157157
*/
158158
InlineTimingFunctionEditor.prototype._handleTimingFunctionChange = function (timingFunctionString) {
159-
var timingFunctionMatch = TimingFunctionUtils.timingFunctionMatch(timingFunctionString, true);
159+
var self = this,
160+
timingFunctionMatch = TimingFunctionUtils.timingFunctionMatch(timingFunctionString, true);
160161
if (timingFunctionMatch !== this._timingFunction) {
161162
var range = this.getCurrentRange();
162163
if (!range) {
@@ -165,12 +166,14 @@ define(function (require, exports, module) {
165166

166167
// Don't push the change back into the host editor if it came from the host editor.
167168
if (!this._isHostChange) {
168-
// Replace old timingFunction in code with the editor's timing function, and select it
169169
this._isOwnChange = true;
170-
this.hostEditor.document.replaceRange(timingFunctionString, range.start, range.end, this._origin);
170+
this.hostEditor.document.batchOperation(function () {
171+
// Replace old timingFunction in code with the editor's timing function, and select it
172+
self.hostEditor.document.replaceRange(timingFunctionString, range.start, range.end, self._origin);
173+
var newEnd = { line: range.start.line, ch: range.start.ch + timingFunctionString.length };
174+
self.hostEditor.setSelection(range.start, newEnd, false, 0, self._origin);
175+
});
171176
this._isOwnChange = false;
172-
var newEnd = { line: range.start.line, ch: range.start.ch + timingFunctionString.length };
173-
this.hostEditor.setSelection(range.start, newEnd, false, 0, this._origin);
174177
}
175178

176179
this._timingFunction = timingFunctionMatch;

0 commit comments

Comments
 (0)