mirror of
https://github.com/anyproto/any-sync.git
synced 2025-06-08 05:57:03 +09:00
Add dump heads and new head when adding text
This commit is contained in:
parent
c5a958df12
commit
3dec56141f
7 changed files with 94 additions and 14 deletions
|
@ -13,7 +13,7 @@ import (
|
|||
type TextDocument interface {
|
||||
tree.ObjectTree
|
||||
InnerTree() tree.ObjectTree
|
||||
AddText(text string) error
|
||||
AddText(text string) (string, error)
|
||||
Text() (string, error)
|
||||
TreeDump() string
|
||||
Close() error
|
||||
|
@ -60,7 +60,7 @@ func (t *textDocument) InnerTree() tree.ObjectTree {
|
|||
return t.ObjectTree
|
||||
}
|
||||
|
||||
func (t *textDocument) AddText(text string) (err error) {
|
||||
func (t *textDocument) AddText(text string) (head string, err error) {
|
||||
content := &testchanges.TextContent_TextAppend{
|
||||
TextAppend: &testchanges.TextAppend{Text: text},
|
||||
}
|
||||
|
@ -76,12 +76,16 @@ func (t *textDocument) AddText(text string) (err error) {
|
|||
}
|
||||
t.Lock()
|
||||
defer t.Unlock()
|
||||
_, err = t.AddContent(context.Background(), tree.SignableChangeContent{
|
||||
addRes, err := t.AddContent(context.Background(), tree.SignableChangeContent{
|
||||
Data: res,
|
||||
Key: t.account.Account().SignKey,
|
||||
Identity: t.account.Account().Identity,
|
||||
IsSnapshot: false,
|
||||
})
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
head = addRes.Heads[0]
|
||||
return
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue