mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
fix problem with setting syntax validation option
This commit is contained in:
parent
c9925a3590
commit
cb4380fa78
1 changed files with 19 additions and 5 deletions
|
@ -15,9 +15,13 @@ define [
|
|||
|
||||
# set the path for ace workers if using a CDN (from editor.jade)
|
||||
if window.aceWorkerPath != ""
|
||||
syntaxValidationEnabled = true
|
||||
ace.config.set('workerPath', "#{window.aceWorkerPath}")
|
||||
else
|
||||
ace.config.setDefaultValue("session", "useWorker", false)
|
||||
syntaxValidationEnabled = false
|
||||
|
||||
# By default, don't use workers - enable them per-session as required
|
||||
ace.config.setDefaultValue("session", "useWorker", false)
|
||||
|
||||
# Ace loads its script itself, so we need to hook in to be able to clear
|
||||
# the cache.
|
||||
|
@ -202,8 +206,12 @@ define [
|
|||
editor.setReadOnly !!value
|
||||
|
||||
scope.$watch "syntaxValidation", (value) ->
|
||||
session = editor.getSession()
|
||||
session.setOption("useWorker", value);
|
||||
# ignore undefined settings here
|
||||
# only instances of ace with an explicit value should set useWorker
|
||||
# the history instance will have syntaxValidation undefined
|
||||
if value? and syntaxValidationEnabled
|
||||
session = editor.getSession()
|
||||
session.setOption("useWorker", value);
|
||||
|
||||
editor.setOption("scrollPastEnd", true)
|
||||
|
||||
|
@ -227,10 +235,16 @@ define [
|
|||
catch
|
||||
mode = "ace/mode/text"
|
||||
|
||||
editor.setSession(new EditSession(lines, mode))
|
||||
# create our new session
|
||||
session = new EditSession(lines, mode)
|
||||
|
||||
session = editor.getSession()
|
||||
session.setUseWrapMode(true)
|
||||
# use syntax validation only when explicitly set
|
||||
if scope.syntaxValidation? and syntaxValidationEnabled
|
||||
session.setOption("useWorker", scope.syntaxValidation);
|
||||
|
||||
# now attach session to editor
|
||||
editor.setSession(session)
|
||||
|
||||
doc = session.getDocument()
|
||||
doc.on "change", onChange
|
||||
|
|
Loading…
Reference in a new issue