Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
x committed Dec 30, 2023
1 parent 31dc2fc commit 20a166a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions components/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ func Completion(ctx context.Context, req *defines.CompletionParams) (result *[]d
return nil, nil
}
proto_file, err := view.ViewManager.GetFile(req.TextDocument.Uri)
if proto_file.Proto() == nil {
return nil, nil
}
line_str := proto_file.ReadLine(int(req.Position.Line))
word := getWord(line_str, int(req.Position.Character-1), false)
if req.Context.TriggerKind != defines.CompletionTriggerKindTriggerCharacter {
Expand Down
6 changes: 3 additions & 3 deletions proto/view/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ func (v *view) setContent(ctx context.Context, document_uri defines.DocumentUri,

v.fileMu.Lock()
defer v.fileMu.Unlock()

if data == nil {
delete(v.filesByURI, document_uri)
return
Expand All @@ -69,8 +68,9 @@ func (v *view) setContent(ctx context.Context, document_uri defines.DocumentUri,
hash: hashContent(data),
},
}
pre := v.filesByURI[document_uri]
pf.proto = pre.Proto()
if pre, ok := v.filesByURI[document_uri]; ok {
pf.proto = pre.Proto()
}
v.filesByURI[document_uri] = pf
// TODO:
// Control times of parse of proto.
Expand Down

0 comments on commit 20a166a

Please sign in to comment.