mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Fix CM/ShareJS adapter using old CM api
Fixes bug where deleting text in CM would throw an error in some circumstances
This commit is contained in:
parent
2ceb7daa97
commit
9cf9a7e4fc
1 changed files with 2 additions and 13 deletions
|
@ -12,21 +12,10 @@ applyCMToShareJS = (editorDoc, delta, doc) ->
|
|||
while i < delta.from.line
|
||||
startPos += editorDoc.lineInfo(i).text.length + 1 # Add 1 for '\n'
|
||||
i++
|
||||
|
||||
startPos += delta.from.ch
|
||||
|
||||
if delta.to.line == delta.from.line &&
|
||||
delta.to.ch == delta.from.ch # Then nothing was removed.
|
||||
doc.insert startPos, delta.text.join '\n'
|
||||
else
|
||||
delLen = delta.to.ch - delta.from.ch
|
||||
while i < delta.to.line
|
||||
delLen += editorDoc.lineInfo(i).text.length + 1 # Add 1 for '\n'
|
||||
i++
|
||||
doc.del startPos, delLen
|
||||
doc.insert startPos, delta.text.join '\n' if delta.text
|
||||
|
||||
applyCMToShareJS editorDoc, delta.next, doc if delta.next
|
||||
doc.del startPos, delta.removed.join('\n').length if delta.removed
|
||||
doc.insert startPos, delta.text.join('\n') if delta.text
|
||||
|
||||
# Attach a CodeMirror editor to the document. The editor's contents are replaced
|
||||
# with the document's contents unless keepEditorContents is true. (In which case
|
||||
|
|
Loading…
Reference in a new issue