Skip to content

Commit

Permalink
Merge pull request #48 from joyme123/fix-completion-empty-file
Browse files Browse the repository at this point in the history
fix(completion): fix completion in empty file
  • Loading branch information
joyme123 authored Oct 22, 2024
2 parents 1f7d75e + 17c72e4 commit 34088d2
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lsp/completion/token_completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,13 @@ func (c *TokenCompletion) Completion(ctx context.Context, ss *cache.Snapshot, cm
break
}
}

if len(prefix) == 0 {
// prefix is empty, set prefix to content
prefix = content
rng.Start.Character = rng.Start.Character - uint32(len(prefix))
}

searchCandidate := func(token string, format protocol.InsertTextFormat) {
if len(token) > len(prefix) && strings.HasPrefix(token, string(prefix)) {
candidates = append(candidates, Candidate{
Expand Down

0 comments on commit 34088d2

Please sign in to comment.