Просмотр исходного кода

In Safari, limit iterations of the command-parsing loop.

Shane Kilkelly 10 лет назад
Родитель
Сommit
4fd4a0372c

+ 19 - 0
services/web/public/coffee/ide/editor/directives/aceEditor/auto-complete/SuggestionManager.coffee

@@ -1,11 +1,30 @@
 define [], () ->
+
+	browserIsSafari = () ->
+		userAgent = navigator.userAgent
+		(
+			userAgent.match(/.*Safari\/.*/) &&
+			!userAgent.match(/.*Chrome\/.*/) &&
+			!userAgent.match(/.*Chromium\/.*/)
+		)
+
+
 	class Parser
 		constructor: (@doc) ->
 
 		parse: () ->
+			limit = null
+			if browserIsSafari()
+				limit = 100
+
 			commands = []
 			seen = {}
+			iterations = 0
 			while command = @nextCommand()
+				iterations += 1
+				if limit && iterations > limit
+					return commands
+
 				docState = @doc
 
 				optionalArgs = 0