internal/lsp: return an updated view after setting a file's contents
Change-Id: I71cfa1463c3f3ec3b80faf9dd57c81d6fa75c466 Reviewed-on: https://go-review.googlesource.com/c/162892 Run-TryBot: Rebecca Stambler <rstambler@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Cottrell <iancottrell@google.com>
This commit is contained in:
parent
e8c45e0433
commit
550322b34f
|
@ -58,7 +58,21 @@ func (v *View) SetContent(ctx context.Context, uri source.URI, content []byte) (
|
||||||
v.mu.Lock()
|
v.mu.Lock()
|
||||||
defer v.mu.Unlock()
|
defer v.mu.Unlock()
|
||||||
|
|
||||||
f := v.getFile(uri)
|
newView := NewView(&v.Config)
|
||||||
|
|
||||||
|
for fURI, f := range v.files {
|
||||||
|
newView.files[fURI] = &File{
|
||||||
|
URI: fURI,
|
||||||
|
view: newView,
|
||||||
|
active: f.active,
|
||||||
|
content: f.content,
|
||||||
|
ast: f.ast,
|
||||||
|
token: f.token,
|
||||||
|
pkg: f.pkg,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
f := newView.getFile(uri)
|
||||||
f.content = content
|
f.content = content
|
||||||
|
|
||||||
// Resetting the contents invalidates the ast, token, and pkg fields.
|
// Resetting the contents invalidates the ast, token, and pkg fields.
|
||||||
|
@ -83,8 +97,7 @@ func (v *View) SetContent(ctx context.Context, uri source.URI, content []byte) (
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(rstambler): We should really return a new, updated view.
|
return newView, nil
|
||||||
return v, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetFile returns a File for the given URI. It will always succeed because it
|
// GetFile returns a File for the given URI. It will always succeed because it
|
||||||
|
|
Loading…
Reference in New Issue