From cee3a885489aa5d238b14d3fdc67975e34681097 Mon Sep 17 00:00:00 2001 From: Max Medvedev Date: Wed, 5 Aug 2026 12:32:42 +0200 Subject: [PATCH] IJPL-252099 fix duplicated prefix (cherry picked from commit c98a44ce047376fea8db120a4d730f67c41bd4eb) GitOrigin-RevId: e0e3da83422e24cb3239c67e989e8ca0d61b6c43 --- .../common/src/protocol/RpcLookupElementEvent.kt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/platform/completion/common/src/protocol/RpcLookupElementEvent.kt b/platform/completion/common/src/protocol/RpcLookupElementEvent.kt index 195b14d4a7d4..35fb75cc8bfd 100644 --- a/platform/completion/common/src/protocol/RpcLookupElementEvent.kt +++ b/platform/completion/common/src/protocol/RpcLookupElementEvent.kt @@ -42,14 +42,23 @@ sealed interface RpcLookupElementEvent { /** * the lookup is closed with completion + * + * [requestId] is the request the chosen item belongs to, and it is what the backend must resolve + * [selectedItemId] against: items live in a per-request storage + * (`BackendCompletionRequestSession.findCompletionResult`), and the mirror lookup's arranger can still belong to an + * older request when this event is handled (IJPL-252099 — the frontend swaps a stale-seeded request for a fresh one + * right before the accept). Resolving against the arranger's own session instead would fail to find the item and + * insert one carrying a shorter prefix matcher, leaving the leading typed characters in the document. */ @Serializable data class ItemSelected( val projectId: ProjectId, + val requestId: RpcCompletionRequestId, val selectedItemId: RpcCompletionItemId? = null, ) : RpcLookupElementEvent { override fun toString(): String = buildToString("ItemSelected") { field("projectId", projectId) + field("requestId", requestId) fieldWithNullDefault("selectedItemId", selectedItemId) } }