From acf996fc14cc8f83fa66359f9fa14aebb1ed4862 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Wed, 29 Mar 2017 20:22:18 -0600 Subject: [PATCH] Speed up cursor blink test --- spec/text-editor-component-spec.js | 4 +++- src/text-editor-component.js | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/spec/text-editor-component-spec.js b/spec/text-editor-component-spec.js index 1d717f753..5866ea947 100644 --- a/spec/text-editor-component-spec.js +++ b/spec/text-editor-component-spec.js @@ -256,9 +256,11 @@ describe('TextEditorComponent', () => { it('blinks cursors when the editor is focused and the cursors are not moving', async () => { assertDocumentFocused() - const {component, element, editor} = buildComponent() + component.props.cursorBlinkPeriod = 40 + component.props.cursorBlinkResumeDelay = 40 editor.addCursorAtScreenPosition([1, 0]) + element.focus() await component.getNextUpdatePromise() const [cursor1, cursor2] = element.querySelectorAll('.cursor') diff --git a/src/text-editor-component.js b/src/text-editor-component.js index 9dc738d08..fd23c72ea 100644 --- a/src/text-editor-component.js +++ b/src/text-editor-component.js @@ -1430,7 +1430,7 @@ class TextEditorComponent { this.cursorsBlinkedOff = true this.startCursorBlinking() this.resumeCursorBlinkingTimeoutHandle = null - }, CURSOR_BLINK_RESUME_DELAY) + }, (this.props.cursorBlinkResumeDelay || CURSOR_BLINK_RESUME_DELAY)) } stopCursorBlinking () { @@ -1448,7 +1448,7 @@ class TextEditorComponent { this.cursorBlinkIntervalHandle = window.setInterval(() => { this.cursorsBlinkedOff = !this.cursorsBlinkedOff this.scheduleUpdate(true) - }, CURSOR_BLINK_PERIOD / 2) + }, (this.props.cursorBlinkPeriod || CURSOR_BLINK_PERIOD) / 2) this.cursorsBlinking = true this.scheduleUpdate(true) }