# NextEditProvider in Continue: How AI Suggests Your Next Code Edit

> Discover the NextEditProvider in Continue. This AI powered feature predicts and suggests your next code edit, enhancing your workflow alongside tab-autocomplete for faster development.

- Repository: [Continue/continue](https://github.com/continuedev/continue)
- Tags: deep-dive
- Published: 2026-06-24

---

**The NextEditProvider is a core feature in the Continue extension that uses an LLM to predict and suggest the next code edit after your current change, working alongside tab-autocomplete to create a "write-then-refine" workflow.**

Built into the `continuedev/continue` repository, the NextEditProvider transforms a simple file edit into an intelligent suggestion pipeline. It captures the context of your recent changes, sends them to a configured language model, and presents the predicted next edit directly in VS Code. This enables developers to maintain flow state by accepting AI-driven refinements with a single keystroke.

## How NextEditProvider Works: The 5-Step Workflow

The provider operates through a structured pipeline that bridges user actions and model inference. Each step is traceable through specific source files in the codebase.

### 1. Context Collection

When you edit a file, the NextEditProvider immediately gathers contextual data to inform the model. According to the type definitions in [`core/nextEdit/types.ts`](https://github.com/continuedev/continue/blob/main/core/nextEdit/types.ts), the system captures:

- **File location**: `fileUri` and `workspaceDirUri` to establish project context
- **Edit history**: `userEdits` containing the diff of recent changes
- **Code excerpts**: `userExcerpts` showing surrounding code for context
- **Editable region**: `originalEditableRange` defining the scope of modification

This data is packaged into a `NextEditOutcome` object that travels through the entire pipeline.

### 2. Prompt Construction

The provider uses template-based prompting defined in [`core/nextEdit/constants.ts`](https://github.com/continuedev/continue/blob/main/core/nextEdit/constants.ts). Depending on the configured model, it selects templates like **Mercury** or **Instinct** to format the context. The prompt includes the current code state, the diff of your recent edits, and metadata required by the specific model provider.

### 3. LLM Request

The constructed prompt is sent to your configured model provider via the generic LLM client. In [`core/core.ts`](https://github.com/continuedev/continue/blob/main/core/core.ts), the NextEdit logic is invoked immediately after a normal autocomplete request finishes. The request includes extra fields defined in `NextEditOutcome` such as `modelName` and `completionId`, allowing full traceability of the inference call.

### 4. Suggestion Processing

When the model returns a completion, the provider interprets it as the *next* edit. The system enriches the raw completion with:
- **Timing data**: `elapsed` field tracking inference duration
- **Cursor positioning**: `finalCursorPosition` for accurate insertion
- **Diff analysis**: `diffLines`, `editableRegionStartLine`, and `editableRegionEndLine` mapping the suggestion to specific line numbers

This creates a complete `NextEditOutcome` object ready for UI presentation.

### 5. UI Presentation and Feedback

The VS Code interface handles the final delivery. The [`NextEditWindowManager.ts`](https://github.com/continuedev/continue/blob/main/NextEditWindowManager.ts) in the extensions layer creates a floating suggestion window, while [`statusBar.ts`](https://github.com/continuedev/continue/blob/main/statusBar.ts) displays a "Next Edit is enabled" indicator in the status bar. Users can **accept** the suggestion with **Tab** (which inserts text and moves the cursor) or **reject** it with **Esc**. These actions are logged back to the provider through `accepted` or `aborted` status updates, enabling the model to learn from your preferences.

## Key Source Files and Architecture

Understanding the NextEditProvider requires familiarity with these specific files in the `continuedev/continue` repository:

- **[`core/nextEdit/types.ts`](https://github.com/continuedev/continue/blob/main/core/nextEdit/types.ts)**: Defines the data model including `NextEditOutcome`, `Prompt`, and related interfaces used throughout the feature lifecycle.
- **[`core/nextEdit/constants.ts`](https://github.com/continuedev/continue/blob/main/core/nextEdit/constants.ts)**: Holds model-specific token identifiers and default prompt templates for Mercury and Instinct models.
- **[`core/core.ts`](https://github.com/continuedev/continue/blob/main/core/core.ts)**: Serves as the integration point where NextEdit logic is triggered after autocomplete requests complete.
- **[`extensions/vscode/src/commands.ts`](https://github.com/continuedev/continue/blob/main/extensions/vscode/src/commands.ts)**: Registers VS Code commands including "Continue: Force Next Edit" and validates that the model supports NextEdit before execution.
- **[`extensions/vscode/src/autocomplete/statusBar.ts`](https://github.com/continuedev/continue/blob/main/extensions/vscode/src/autocomplete/statusBar.ts)**: Manages the status bar indicator and toggle functionality for enabling or disabling the feature.
- **[`extensions/vscode/src/activation/NextEditWindowManager.ts`](https://github.com/continuedev/continue/blob/main/extensions/vscode/src/activation/NextEditWindowManager.ts)**: Controls the floating suggestion widget and routes Tab/Esc keybindings to the provider's accept and abort methods.

## Working with NextEditProvider Programmatically

You can interact with the NextEditProvider directly through the VS Code extension API or internal core methods.

### Trigger a NextEdit Suggestion

Force the provider to generate a suggestion for the active editor using the registered command:

```typescript
// From extensions/vscode/src/commands.ts
registerCommand("Continue: Force Next Edit", async () => {
  await nextEditProvider.forceNextEdit();   // Forces immediate suggestion generation
});

```

### Accept a Suggestion

When a suggestion appears, accept it programmatically to insert the text and log the outcome:

```typescript
// From extensions/vscode/src/activation/NextEditWindowManager.ts
const accept = async () => {
  await nextEditProvider.acceptSuggestion(); // Inserts completion and records acceptance
};

```

### Reject a Suggestion

Abort the current suggestion and record the rejection:

```typescript
// Capture Esc key to abort
const reject = async () => {
  await nextEditProvider.abortSuggestion(); // Removes widget and logs abort event
};

```

### Inspect the Outcome Object

For debugging or custom analytics, examine the complete `NextEditOutcome` structure:

```typescript
import { NextEditOutcome } from "core/nextEdit/types";

function logOutcome(outcome: NextEditOutcome) {
  console.log({
    model: `${outcome.modelProvider}/${outcome.modelName}`,
    accepted: outcome.accepted,
    elapsedMs: outcome.elapsed,
    cursor: outcome.finalCursorPosition,
    diff: outcome.diffLines.map(l => `${l.type} ${l.content}`).join("\n")
  });
}

```

## Summary

- The **NextEditProvider** predicts your next code edit using LLM inference triggered by file changes.
- It collects context from [`core/nextEdit/types.ts`](https://github.com/continuedev/continue/blob/main/core/nextEdit/types.ts) fields including `userEdits`, `fileUri`, and `originalEditableRange`.
- Prompts are built using templates from [`core/nextEdit/constants.ts`](https://github.com/continuedev/continue/blob/main/core/nextEdit/constants.ts) and executed through [`core/core.ts`](https://github.com/continuedev/continue/blob/main/core/core.ts).
- The VS Code integration layers handle UI rendering in [`NextEditWindowManager.ts`](https://github.com/continuedev/continue/blob/main/NextEditWindowManager.ts) and command registration in [`commands.ts`](https://github.com/continuedev/continue/blob/main/commands.ts).
- Users accept suggestions with **Tab** or reject with **Esc**, with outcomes logged via `accepted` and `aborted` flags.

## Frequently Asked Questions

### What is the difference between NextEditProvider and regular autocomplete?

**Regular autocomplete** suggests code completions based on cursor position and context, typically filling in the current line or block. **NextEditProvider** specifically analyzes the *diff* of your recent edits and predicts the *next* logical change you should make, creating a sequential editing workflow rather than just completion. While autocomplete runs continuously, NextEdit activates after you make a change and suggests the subsequent modification.

### How do I enable or disable NextEditProvider in VS Code?

The feature can be toggled through the status bar indicator managed in [`extensions/vscode/src/autocomplete/statusBar.ts`](https://github.com/continuedev/continue/blob/main/extensions/vscode/src/autocomplete/statusBar.ts). The code checks that tab-autocomplete is enabled before activating NextEdit, and displays a warning if your configured model does not support the feature. You can also force a NextEdit session using the "Continue: Force Next Edit" command registered in [`extensions/vscode/src/commands.ts`](https://github.com/continuedev/continue/blob/main/extensions/vscode/src/commands.ts).

### Which models support NextEditProvider?

Support depends on the model's ability to process diff-based prompts and return structured completions. The [`core/nextEdit/constants.ts`](https://github.com/continuedev/continue/blob/main/core/nextEdit/constants.ts) file defines model-specific constants and templates for supported models like **Mercury** and **Instinct**. If your model lacks support, the system will show a warning when you attempt to enable the feature, as implemented in the command validation logic in [`commands.ts`](https://github.com/continuedev/continue/blob/main/commands.ts).

### How does NextEditProvider learn from my feedback?

Every accept or reject action is logged back to the provider through the `NextEditOutcome` object. The `accepted` boolean field tracks whether you pressed **Tab** to insert the suggestion, while the `aborted` field records **Esc** rejections. This feedback loop, implemented in [`NextEditWindowManager.ts`](https://github.com/continuedev/continue/blob/main/NextEditWindowManager.ts), allows the system to track suggestion quality and can be used to fine-tune model performance or prompt templates over time.