fix path bugs

This commit is contained in:
Kevin Jahns
2017-11-10 12:54:33 -08:00
parent d232b883e9
commit 0cda1630d2
8 changed files with 47 additions and 38 deletions

View File

@@ -1,5 +1,6 @@
import Type from '../Struct/Type.js'
import ItemJSON from '../Struct/ItemJSON.js'
import ItemString from '../Struct/ItemString.js'
import { logID } from '../MessageHandler/messageToString.js'
import YEvent from '../Util/YEvent.js'
@@ -19,7 +20,11 @@ export default class YArray extends Type {
while (n !== null) {
if (!n._deleted) {
if (pos < n._length) {
return n._content[n._length - pos]
if (n.constructor === ItemJSON || n.constructor === ItemString) {
return n._content[pos]
} else {
return n
}
}
pos -= n._length
}

View File

@@ -255,7 +255,7 @@ export default class YXmlFragment extends YArray {
}
})
for (let dom of diffChildren) {
if (dom._yxml != null) {
if (dom._yxml != null && dom._yxml !== false) {
applyChangesFromDom(dom)
}
}

View File

@@ -76,7 +76,6 @@ export default class UndoManager {
if (!this._undoing) {
let lastUndoOp = this._undoBuffer.length > 0 ? this._undoBuffer[this._undoBuffer.length - 1] : null
if (lastUndoOp !== null && reverseOperation.created - lastUndoOp.created <= options.captureTimeout) {
console.log('appending', lastUndoOp, reverseOperation)
lastUndoOp.created = reverseOperation.created
lastUndoOp.toState = reverseOperation.toState
reverseOperation.deletedStructs.forEach(lastUndoOp.deletedStructs.add, lastUndoOp.deletedStructs)
@@ -93,7 +92,6 @@ export default class UndoManager {
})
}
undo () {
console.log('undoing')
this._undoing = true
const performedUndo = applyReverseOperation(this.y, this._scope, this._undoBuffer)
this._undoing = false

View File

@@ -8,15 +8,15 @@ export default class YEvent {
const path = []
let type = this.target
const y = type._y
while (type._parent !== this._currentTarget && type._parent !== y) {
while (type !== this.currentTarget && type !== y) {
let parent = type._parent
if (type._parentSub !== null) {
path.push(type._parentSub)
path.unshift(type._parentSub)
} else {
// parent is array-ish
for (let [i, child] of parent) {
if (child === type) {
path.push(i)
path.unshift(i)
break
}
}