fix empty string insertion bug
This commit is contained in:
parent
f2debc150c
commit
fc5be5c7cc
@ -24,6 +24,9 @@ export default class YText extends YArray {
|
|||||||
return strBuilder.join('')
|
return strBuilder.join('')
|
||||||
}
|
}
|
||||||
insert (pos, text) {
|
insert (pos, text) {
|
||||||
|
if (text.length <= 0) {
|
||||||
|
return
|
||||||
|
}
|
||||||
this._transact(y => {
|
this._transact(y => {
|
||||||
let left = null
|
let left = null
|
||||||
let right = this._start
|
let right = this._start
|
||||||
|
@ -11,6 +11,10 @@ export default class ID {
|
|||||||
return id !== null && id.user === this.user && id.clock === this.clock
|
return id !== null && id.user === this.user && id.clock === this.clock
|
||||||
}
|
}
|
||||||
lessThan (id) {
|
lessThan (id) {
|
||||||
return this.user < id.user || (this.user === id.user && this.clock < id.clock)
|
if (id.constructor === ID) {
|
||||||
|
return this.user < id.user || (this.user === id.user && this.clock < id.clock)
|
||||||
|
} else {
|
||||||
|
return false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,10 @@ export default class RootID {
|
|||||||
return id !== null && id.user === this.user && id.name === this.name && id.type === this.type
|
return id !== null && id.user === this.user && id.name === this.name && id.type === this.type
|
||||||
}
|
}
|
||||||
lessThan (id) {
|
lessThan (id) {
|
||||||
return this.user < id.user || (this.user === id.user && (this.name < id.name || (this.name === id.name && this.type < id.type)))
|
if (id.constructor === RootID) {
|
||||||
|
return this.user < id.user || (this.user === id.user && (this.name < id.name || (this.name === id.name && this.type < id.type)))
|
||||||
|
} else {
|
||||||
|
return true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user