Files
vscode/extensions
ae0e51e824 nes: fix: NES cached suggestion not shown after rebasing over user indentation (#326537)
* Fix NES cached suggestion not shown after rebasing over user indentation

When a cached NES suggestion is a line-based insertion that restates the
line's indentation (e.g. predicting "    return [" on an empty body line)
and the user tabs to indent that line, tryRebaseCacheEntry served the raw,
non-minimized edit whose range spans the indentation the user already
typed. That edit is not a clean at-cursor insertion, so the core
inline-completions renderer drops it and the cached suggestion is silently
not shown.

Minimize the served rebased edit via removeCommonSuffixAndPrefix so the
indentation the user already typed is stripped, yielding a clean at-cursor
insertion that renders as ghost text. This is semantically neutral (same
apply() result on the current document) and idempotent for the downstream
isRejectedNextEdit check. Minimizing is done at the cache serving layer
rather than in editRebase, which intentionally keeps the full line edit for
response/telemetry fidelity.

Adds a regression test covering the empty-line + tab scenario.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 02c9dab3-1534-4b24-86c1-410c66e9d550

* Salvage NES suggestion on rebaseFailed for indentation mismatch

The previous commit minimized the served edit in the rebase *success*
branch, but that path already renders as ghost text, so the change was a
semantic no-op and its test modeled an artificial success path.

The real bug is in the rebase *failure* path: strict rebase matches
indentation literally, so when the user re-types a line's leading
whitespace differently than the model predicted (e.g. pressing Tab to
insert a tab character, or a different number of spaces, on an empty body
line), the whole suggestion is silently dropped and nothing is shown.

Salvage that case in the cache layer: on `rebaseFailed`, re-anchor the
model's still-valid content as a clean at-cursor insertion that respects
the indentation the user actually typed. This mirrors the reconciliation
the engine already performs when the indentation matches, is a faithful
representation of the model's intent (so it upholds the display layer's
soundness invariant), and only fires when the suggestion would otherwise
be dropped.

Revert the no-op minimization and replace the misleading regression test
with a faithful one covering the tab-character drop scenario (which fails
without this salvage).

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 02c9dab3-1534-4b24-86c1-410c66e9d550

* Gate NES indentation-mismatch salvage behind a setting

Put the rebaseFailed re-anchoring behavior behind a new team-internal,
experiment-based setting `chat.advanced.inlineEdits.reanchorContentOnIndentationMismatch`
(default off) so it can be rolled out or disabled independently.

Thread the flag through `NesRebaseConfigs` (built in `_getNesRebaseConfigs`)
and gate the `tryReanchorContentAfterIndentation` salvage call on it. Add a
regression test asserting the suggestion is dropped when the setting is
disabled, alongside the existing salvage test with it enabled.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 02c9dab3-1534-4b24-86c1-410c66e9d550

---------

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-07-20 16:24:20 +05:00
..
2026-07-10 12:59:32 +00:00
2026-07-14 12:34:04 +02:00