You are writing a function in Visual Studio Code or another supported IDE, and GitHub Copilot suddenly stops offering inline suggestions halfway through. The ghost text disappears, and pressing Tab or Enter does nothing. This interruption can break your flow and slow down development. The cause is usually a combination of context limits, token restrictions, or incorrect editor settings. This article explains the technical reasons behind this behavior and provides specific steps to restore Copilot’s suggestions.
Key Takeaways: Restoring GitHub Copilot Suggestions Mid-Function
- Copilot context window limit of 4096 tokens: Exceeding this limit causes Copilot to stop suggesting until you reduce the visible code or open a new file.
- Copilot: Disable Inline Suggestions toggle in VS Code settings: Turning this off and on again resets the suggestion engine without restarting the editor.
- GitHub Copilot status bar icon in VS Code: Click the Copilot icon in the bottom-right corner to check connection status and enable or disable suggestions per file.
Why Copilot Stops Suggesting Mid-Function
GitHub Copilot uses a machine learning model that has a fixed context window. The context window is the amount of code the model can “see” at once when generating a suggestion. For Copilot, this window is approximately 4096 tokens. A token is roughly one word or code element. When the total tokens in the current file plus the function you are writing exceed this limit, Copilot cannot process the entire context and stops providing suggestions.
Another factor is the stop sequence mechanism. Copilot looks for natural breaking points in your code, such as a closing brace, a semicolon, or a blank line. If your function contains a complex nested block or a long string literal, Copilot may interpret a partial structure as a stopping point and cease generating suggestions.
Additionally, Copilot relies on the language server protocol (LSP) to communicate with your editor. If the LSP crashes or becomes unresponsive, Copilot stops sending suggestions. This can happen when the editor runs out of memory or when a plugin conflicts with Copilot.
Token Limit in Detail
The 4096-token limit includes the entire file content, not just the function you are editing. A file with many imports, long comments, or large data structures uses tokens quickly. When you reach the limit, Copilot either stops suggesting entirely or provides very short, irrelevant completions. You can verify this by opening a new file and pasting only the function body. If Copilot suggests normally in the new file, the original file exceeded the token limit.
Stop Sequences and Heuristics
Copilot uses heuristics to decide when to stop suggesting. Common stop sequences include:
- Closing braces
}at the same indentation level as the function start - Unmatched parentheses or brackets
- A line with only whitespace after a complete statement
- A comment that abruptly changes topic
If your function contains any of these patterns mid-way, Copilot may incorrectly assume the function is complete and stop suggesting.
Steps to Restore Copilot Suggestions When They Stop Mid-Function
- Check the Copilot status icon
In VS Code, look at the bottom-right corner of the window for the Copilot icon. It shows a checkmark when active, a spinning circle when loading, or a crossed-out circle when disabled. If it is crossed out, click the icon and select Enable Completions. - Toggle inline suggestions off and on
Open the Command Palette with Ctrl+Shift+P. Type Copilot: Disable Inline Suggestions and press Enter. Then immediately type Copilot: Enable Inline Suggestions and press Enter. This resets the suggestion engine without restarting VS Code. - Reduce the visible code in the current file
Collapse all function definitions, class declarations, and import blocks that are not needed for the current function. Use Ctrl+K Ctrl+0 to collapse all regions. This reduces the token count and may bring Copilot back within its context window. - Split the function into smaller helper functions
If the function is longer than 50 lines, refactor it into multiple smaller functions. Copilot works better with shorter, single-purpose functions. Create a helper function for a distinct block of logic and call it from the main function. - Restart the Copilot language server
Open the Command Palette with Ctrl+Shift+P. Type Developer: Reload Window and press Enter. This restarts all extensions including Copilot. Alternatively, you can run Copilot: Restart Copilot if available in your version. - Check for conflicting extensions
Disable other code completion extensions such as Tabnine, IntelliCode, or Kite. Go to the Extensions view with Ctrl+Shift+X, find each extension, and click Disable. Reload the window and test Copilot suggestions. - Update GitHub Copilot to the latest version
In VS Code, open the Extensions view with Ctrl+Shift+X. Find GitHub Copilot, click the gear icon, and select Update if available. Outdated versions may have bugs that cause suggestion drops. - Clear the Copilot cache
Close VS Code. Navigate to the Copilot cache folder: on Windows,%APPDATA%\Code\CachedData; on macOS,~/Library/Application Support/Code/CachedData. Delete the contents of this folder. Restart VS Code and open your file again.
If Copilot Still Has Issues After the Main Fix
Copilot Suggests Only One Line at a Time
This usually indicates a token limit issue. The model can only generate a short completion because the context is too large. Follow the steps above to reduce visible code. Also, check if you have a very long string literal or a large JSON object in the file. Move such data to a separate file and import it.
Copilot Suggests Irrelevant Code
When Copilot runs out of context, it may suggest completions based on unrelated files or patterns. This happens because the model falls back to its training data instead of the current file’s context. To fix this, close all tabs except the one you are editing. Copilot uses all open files as context. Fewer open files mean a cleaner context.
Copilot Stops Suggesting After a Specific Keystroke
If Copilot stops after you type a certain character or keyword, the issue is likely a stop sequence. For example, typing a closing brace at the wrong indentation can trigger a stop. Check your indentation and ensure braces are at the correct level. If the function uses a loop or conditional, verify that all brackets are properly matched.
GitHub Copilot Free vs Copilot Pro: Key Differences
| Item | GitHub Copilot Free | GitHub Copilot Pro |
|---|---|---|
| Monthly price | $0 | $10 per user per month |
| Context window | 4096 tokens | 4096 tokens |
| Suggestions per request | 1 | Up to 10 alternatives |
| Copilot Chat access | Limited (2000 messages per month) | Unlimited |
| Supported IDEs | VS Code, JetBrains, Neovim | All Copilot-supported IDEs |
Both plans have the same token limit, so the mid-function stopping issue affects Free and Pro users equally. The main advantage of Pro is the ability to cycle through multiple suggestions with Alt+] and Alt+[ and to use Copilot Chat without message limits.
You can now identify why Copilot stops suggesting mid-function and apply the correct fix. Start by checking the status icon and toggling inline suggestions. If the issue persists, reduce visible code or refactor long functions. For persistent problems, restart the Copilot language server or clear the cache. As an advanced tip, you can set editor.inlineSuggest.enabled to false and true in your VS Code settings.json to force a full reset of the inline suggestion pipeline without using the Command Palette.