Permalink
Browse files

Fix detach_ace - not all listeners were being removed

  • Loading branch information...
1 parent 7a953a8 commit bae74fe67c5def81f4b02018ebdc497a7686c604 @obijywk committed Nov 15, 2012
Showing with 14 additions and 8 deletions.
  1. +4 −2 src/client/ace.coffee
  2. +5 −3 webclient/ace.js
  3. +5 −3 webclient/share-ace.js
View
@@ -106,20 +106,22 @@ window.sharejs.extendDoc 'attach_ace', (editor, keepEditorContents) ->
row:row, column:offset
- doc.on 'insert', (pos, text) ->
+ doc.on 'insert', insertListener = (pos, text) ->
suppress = true
editorDoc.insert offsetToPos(pos), text
suppress = false
check()
- doc.on 'delete', (pos, text) ->
+ doc.on 'delete', deleteListener = (pos, text) ->
suppress = true
range = Range.fromPoints offsetToPos(pos), offsetToPos(pos + text.length)
editorDoc.remove range
suppress = false
check()
doc.detach_ace = ->
+ doc.removeListener 'insert', insertListener
+ doc.removeListener 'delete', deleteListener
doc.removeListener 'remoteop', docListener
editorDoc.removeListener 'change', editorListener
delete doc.detach_ace
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

0 comments on commit bae74fe

Please sign in to comment.