summaryrefslogtreecommitdiff
path: root/internal/lsp/handlers_completion.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-03-10 19:34:02 +0200
committerPaul Buetow <paul@buetow.org>2026-03-10 19:34:02 +0200
commitde5029e6d4a7efffcccfb08d98770b1c1c4f54fe (patch)
tree7429b9a72c96393ca74d323faf4f989224e83db0 /internal/lsp/handlers_completion.go
parentba4b4b340b17450fa86122f227a75ef054e0ad53 (diff)
task bf088a70: extract LSP client and completion state
Diffstat (limited to 'internal/lsp/handlers_completion.go')
-rw-r--r--internal/lsp/handlers_completion.go34
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{