Sub topic 3
Where the Next Edit Goes and How It Is Shown as a Diff
Assume you know basic IDE editing, diffs, and how a language model predicts text. This chapter focuses on next edit suggestions (NES): predictions about a future change and its location, rather than only text inserted at the cursor.
Finding the Edit Location
An NES system examines recent edits, the current file, nearby symbols, diagnostics, and sometimes related files. It predicts both:
- Where the next change belongs, such as a function call or test.
- What change should be made there.
The editor usually represents the prediction as a patch. Added text appears in green, removed text in red, and unchanged context anchors the change.
A location prediction can fail even when the proposed text is valid. For example, the model may update a helper function when the intended change belongs at its caller. Anchors such as symbol names, line ranges, and surrounding text help the editor apply a patch safely.
Completions or Next Edit Suggestions?
| Feature | Inline completion | Next edit suggestion |
|---|---|---|
| Input | Cursor and surrounding context | Recent edits plus broader project context |
| Output | Text at the cursor | A patch at a predicted location |
| Best use | Finish a line or block | Continue a repeated refactor or related change |
Use an inline completion when you know where you are typing. Use NES when your last change implies another change elsewhere, such as updating call sites after renaming parameters.
Measuring Quality
Track several measures together:
- Acceptance rate: the percentage of suggestions accepted, wholly or partly.
- Latency: time from the trigger to a usable suggestion.
- Retention: how often accepted text remains after later edits, or is not immediately undone.
A high acceptance rate with poor retention can indicate that suggestions look plausible but create rework. Segment results by language, repository, suggestion size, and user workflow.
Privacy, Licensing, and Data Handling
Before enabling a feature, check which code and edit history leave the machine, how long the provider stores them, and whether administrators can disable collection. Apply repository-specific settings for confidential code. Generated code can resemble licensed or copyrighted code, so review provider terms and your organization's source-usage policy.
Failure Modes and Safe Review
Common failures include stale locations, edits applied to the wrong symbol, duplicated changes, and patches that pass local checks but violate business rules. Review the diff before accepting it. Check the target symbol, surrounding assumptions, tests, diagnostics, and security-sensitive behavior. Accept a small part when only part is correct, then run formatting, tests, and static analysis.
Exercise
Which feature is a better fit for changing several related call sites after a parameter rename: inline completion or NES?
Show answer
NES, because it predicts an edit location and patch from the recent rename rather than only completing text at the cursor.