Merge branch 'sk-safari-freeze-fix'

This commit is contained in:
Shane Kilkelly 2016-04-11 14:47:03 +01:00
commit 749d2aa013
2 changed files with 25 additions and 0 deletions

View file

@ -112,4 +112,17 @@ define [
ide.localStorage = localStorage
ide.browserIsSafari = false
try
userAgent = navigator.userAgent
ide.browserIsSafari = (
userAgent &&
userAgent.match(/.*Safari\/.*/) &&
!userAgent.match(/.*Chrome\/.*/) &&
!userAgent.match(/.*Chromium\/.*/)
)
catch err
console.error err
angular.bootstrap(document.body, ["SharelatexApp"])

View file

@ -1,11 +1,23 @@
define [], () ->
class Parser
constructor: (@doc) ->
parse: () ->
# Safari regex is super slow, freezes browser for minutes on end,
# hacky solution: limit iterations
limit = null
if window?._ide?.browserIsSafari
limit = 100
commands = []
seen = {}
iterations = 0
while command = @nextCommand()
iterations += 1
if limit && iterations > limit
return commands
docState = @doc
optionalArgs = 0