diff options
Diffstat (limited to 'internal/lsp/handlers_completion.go')
| -rw-r--r-- | internal/lsp/handlers_completion.go | 34 |
1 files changed, 1 insertions, 33 deletions
diff --git a/internal/lsp/handlers_completion.go b/internal/lsp/handlers_completion.go index 3009d50..7c293b0 100644 --- a/internal/lsp/handlers_completion.go +++ b/internal/lsp/handlers_completion.go @@ -63,7 +63,7 @@ func (s *Server) handleCompletion(req Request) { if s.logContext { s.logCompletionContext(p, above, current, below, funcCtx) } - if s.llmClient != nil { + if s.currentLLMClient() != nil { newFunc := s.isDefiningNewFunction(p.TextDocument.URI, p.Position) extra, has := s.buildAdditionalContext(newFunc, p.TextDocument.URI, p.Position) items, ok, incomplete := s.tryLLMCompletion(p, above, current, below, funcCtx, docStr, has, extra) @@ -512,38 +512,6 @@ func (s *Server) waitForDebounce(ctx context.Context) { } } -// waitForThrottle enforces a minimum spacing between LLM calls. Returns false -// if the context is canceled while waiting. -func (s *Server) waitForThrottle(ctx context.Context) bool { - interval := s.completionThrottle() - if interval <= 0 { - return true - } - var wait time.Duration - for { - s.mu.Lock() - next := s.lastLLMCall.Add(interval) - now := time.Now() - if now.Before(next) { - wait = next.Sub(now) - s.mu.Unlock() - timer := time.NewTimer(wait) - select { - case <-ctx.Done(): - timer.Stop() - return false - case <-timer.C: - // try again to set the next call time - continue - } - } - // we are allowed to proceed now; record this call as the latest - s.lastLLMCall = now - s.mu.Unlock() - return true - } -} - // buildCompletionMessages constructs the LLM messages for completion. func (s *Server) buildCompletionMessages(inlinePrompt, hasExtra bool, extraText string, inParams bool, p CompletionParams, above, current, below, funcCtx string) []llm.Message { vars := map[string]string{ |
