Completion suggests something confidently wrong several times a day, and people treat it as inherent to the tool. Most of it comes from a short list of causes, and three of them are things you control.
What are the causes?
- It cannot see the relevant code. The definition is in a file that is not open.
- The names mislead it. A function called differently from what it does.
- There is nothing to go on. An empty file or an unusual approach.
- Stale context. It is working from an earlier state of the file.
- The training data disagrees. Your project does something unconventional.
Why do names matter so much?
Because the suggestion is predicted largely from them. A function named to fetch a user will be completed as though it fetches a user, regardless of what the surrounding code implies, and a badly named function produces confidently wrong completions every time it is touched.
This is a genuine argument for careful naming that has nothing to do with readability.
The suggestion is also influenced by anything similar already in the file, which is why the second and third cases of a pattern complete almost perfectly and the first one rarely does.
How do you steer it deliberately?
Write a comment first. A line describing what the next block should do is the most direct control available over inline completion, since it supplies the intent that the tool otherwise has to guess.
Writing the function signature and the first line has the same effect, and both are faster than rejecting three suggestions.
Recently edited files also influence suggestions in some tools, which explains the pattern where completion improves noticeably after you open the file containing the definitions it needed.
Why does it invent methods that do not exist?
Because it is producing what a method of that name plausibly would be. A library that almost has the function you want will be completed as though it has it, and the code is syntactically perfect and fails at runtime.
This is the most common failure with unfamiliar libraries and the reason to check anything you did not already know existed.
Unusual approaches attract wrong suggestions most persistently, since the tool keeps proposing the conventional version of what you are deliberately doing differently.
What about the wrong version?
Frequent and hard to spot. Completion reflects what was common in training, so a framework that changed its interface produces suggestions for the previous one, which look entirely correct.
Stating versions in the project rules file addresses this better than anything done per suggestion.
Why does it get worse in a long file?
Because the window around the cursor covers less of it, so definitions at the top become invisible while you work at the bottom. Long files degrade completion quality noticeably, which is another reason to keep them shorter.
What should you do about repeated bad suggestions?
Open the file it needs, or turn completion off for that section. Fighting a suggestion that keeps returning is the least productive minute available, and both alternatives take seconds.
Should you accept a suggestion you would not have written?
Only after reading it properly, which is the discipline that erodes fastest. A suggestion doing something in an unfamiliar way is either teaching you something or introducing something you cannot maintain, and the two are indistinguishable at the moment of pressing accept.
The useful habit is to pause on anything unfamiliar and ask what it does before accepting. That costs a few seconds several times a day and it is the main protection against a codebase gradually filling with constructions nobody in the team chose.
What is the underlying point?
Completion predicts from what is visible. Every fix is about changing what is visible: opening the right file, naming things honestly, writing a comment first, or shortening the file. None of it involves the tool being better.