Skip to content

Commit b27f334

Browse files
committed
feat: add version support in documents
1 parent f4253b2 commit b27f334

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

source.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,7 @@ func (doc *EditableDocument) Reset() {
496496
}
497497

498498
type Document struct {
499+
Version int
499500
Path string
500501
Contents string
501502
cachedLines []string
@@ -537,6 +538,11 @@ func (doc *Document) TotalLines() int {
537538
}
538539

539540
func ParseDocument(path string, r io.Reader, parser *sitter.Parser, selectLang *Language, existingDoc *Document) (*Document, error) {
541+
version := 1
542+
if existingDoc != nil {
543+
version = existingDoc.Version + 1
544+
}
545+
540546
inputBytes, err := io.ReadAll(r)
541547
if err != nil {
542548
return nil, err
@@ -571,5 +577,6 @@ func ParseDocument(path string, r io.Reader, parser *sitter.Parser, selectLang *
571577
Language: selectLang,
572578
Contents: string(inputBytes),
573579
Tree: tree,
580+
Version: version,
574581
}, nil
575582
}

0 commit comments

Comments
 (0)