From ca93ec510d4722c0c17f53b0bcada6e9b8225379 Mon Sep 17 00:00:00 2001 From: Guillaume Sabran Date: Thu, 15 Jan 2026 11:43:41 -0800 Subject: [PATCH] Fix completion expansion --- .../Sources/CodeCompletionViewModel.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/modules/features/CodeCompletionFeature/Sources/CodeCompletionViewModel.swift b/app/modules/features/CodeCompletionFeature/Sources/CodeCompletionViewModel.swift index fa0f8955..602fd13e 100644 --- a/app/modules/features/CodeCompletionFeature/Sources/CodeCompletionViewModel.swift +++ b/app/modules/features/CodeCompletionFeature/Sources/CodeCompletionViewModel.swift @@ -512,11 +512,14 @@ final class CodeCompletionViewModel { if let (cacheId, cachedCompletion) = try? codeCompletionService.cachedCompletion(completionRequest) { defaultLogger.log("Using cached completion \(cachedCompletion?.diff.debugDescription ?? "nil")") - completion = cachedCompletion cachedRequestId = cacheId + // completionTask must be set before completion to ensure that when completion's didSet + // triggers needsLayout() -> getFrame(), the completionTask is available for screenshot capture completionTask = CompletionTask( id: taskId, request: .init(fileURL: editorState.fileURL, content: editorState.content, selection: selection)) + completion = cachedCompletion + isCompletionExpanded = settingsService.value(for: \.multiLineCodeCompletionDisplayMode).isAlwaysShown } else { let task = Task { [weak self] in do {