mirror of
https://github.com/microsoft/vscode.git
synced 2026-07-07 15:26:49 +01:00
e1f9e64d67
* nes: dedupe NextEditProvider streamed-edit handling into shared helper Extract the per-edit rebase+cache logic shared by the regular fetch path (`_executeNewNextEditRequest`) and the speculative path (`_runSpeculativeProviderCall`) into a single `_cacheStreamedEdit` method. Both loops previously open-coded the same convert -> rebase -> compose -> setKthNextEdit -> cross-file cache pipeline, which had started to drift. Also: - extract the inline doc-state type into a named `DocState` interface and mark the non-reassigned fields `readonly` - reuse the existing exported `StreamedEdit` type instead of a local duplicate Behavior-preserving: the only differences are trace-level log messages. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * nes: rename _cacheStreamedEdit to _rebaseAndCacheStreamedEdit The method does more than cache: it also rebases the streamed edit onto the edits applied so far and mutates the per-doc accumulators. The new name reflects that wider responsibility. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * nes: pass _rebaseAndCacheStreamedEdit args as an options object Replace the nine positional parameters with a single typed RebaseAndCacheStreamedEditArgs object and group the active-document fields (id, contents, cursorOffset) under `activeDoc`. This removes the call-site ambiguity of several same-typed/optional positional arguments. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * nes: let _rebaseAndCacheStreamedEdit own docContents advancement Previously the helper mutated editsSoFar/nextEdits/patchIndices and the cache, but left advancing the target document's running `docContents` to each caller (a foot-gun: a future caller could forget it, desyncing the cache key from subsequent edits). The helper now owns the full per-edit state transition: it snapshots the pre-edit contents, populates the cache against that snapshot, then advances `docContents`. The snapshot is returned as `docContentsBeforeEdit` so the regular path can still log the first edit against the pre-edit contents. `targetDocState` is no longer returned, so callers can't mutate it. Behavior-preserving. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * nes: drop redundant targetDocument fallback in _rebaseAndCacheStreamedEdit StreamedEdit.targetDocument is a required DocumentId, so the `?? activeDoc.id` fallback was dead code that could mislead readers into thinking targetDocument may be omitted. Addresses PR review feedback. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>