From 1b70e08f82fe17ea4705c4232811b194ff47b062 Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Fri, 18 Dec 2015 09:55:24 +0000 Subject: [PATCH] reinstate the chaosmonkey --- .../public/coffee/ide/editor/Document.coffee | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/services/web/public/coffee/ide/editor/Document.coffee b/services/web/public/coffee/ide/editor/Document.coffee index 1927b791da..719865e49e 100644 --- a/services/web/public/coffee/ide/editor/Document.coffee +++ b/services/web/public/coffee/ide/editor/Document.coffee @@ -116,6 +116,26 @@ define [ flush: () -> @doc?.flushPendingOps() + chaosMonkey: (line = 0, char = "a") -> + orig = char + copy = null + pos = 0 + timer = () => + unless copy? and copy.length + copy = orig.slice() + ' ' + new Date() + '\n' + line += if Math.random() > 0.1 then 1 else -2 + line = 0 if line < 0 + pos = 0 + char = copy[0] + copy = copy.slice(1) + @ace.session.insert({row: line, column: pos}, char) + pos += 1 + @_cm = setTimeout timer, 100 + if Math.random() < 0.1 then 1000 else 0 + @_cm = timer() + + clearChaosMonkey: () -> + clearTimeout @_cm + pollSavedStatus: () -> # returns false if doc has ops waiting to be acknowledged or # sent that haven't changed since the last time we checked.