From 90aa33d42500d494effbfa6ba6df41bfa529b690 Mon Sep 17 00:00:00 2001 From: njucz Date: Fri, 29 May 2020 17:47:01 +0800 Subject: [PATCH] change to "setVersion" func --- internal/filesystem/file.go | 4 ++-- internal/filesystem/filesystem.go | 3 +-- internal/lsp/file_change.go | 5 +++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/filesystem/file.go b/internal/filesystem/file.go index fd6fab243..d889e7b4e 100644 --- a/internal/filesystem/file.go +++ b/internal/filesystem/file.go @@ -47,8 +47,8 @@ func (f *file) Version() int { return f.version } -func (f *file) IncrementVersion() { - f.version += 1 +func (f *file) SetVersion(version int) { + f.version = version } func (f *file) Lines() source.Lines { diff --git a/internal/filesystem/filesystem.go b/internal/filesystem/filesystem.go index 5f798e2db..0cf518e4b 100644 --- a/internal/filesystem/filesystem.go +++ b/internal/filesystem/filesystem.go @@ -55,8 +55,7 @@ func (fs *fsystem) Change(fh VersionedFileHandler, changes FileChanges) error { for _, change := range changes { f.applyChange(change) } - - f.IncrementVersion() + f.SetVersion(fh.Version()) return nil } diff --git a/internal/lsp/file_change.go b/internal/lsp/file_change.go index df47614b3..01e6d90d9 100644 --- a/internal/lsp/file_change.go +++ b/internal/lsp/file_change.go @@ -7,8 +7,9 @@ import ( ) type fileChange struct { - text string - rng hcl.Range + text string + rng hcl.Range + version int } func FileChange(chEvent lsp.TextDocumentContentChangeEvent, f File) (*fileChange, error) {