I'll reproduce a generic example I sent a friend.
Prompt:
const redis = require('redis');
// Create a redis client
Copilot suggested: const client = redis.createClient();
I accepted it and moved 2 lines down, prompt: // Get the current count from redis
Copilot suggested a start to the operation: client.get('count', (err, count) => {
I accepted it, and Copilot continued: if (err) {
console.log(err);
return;
}
// If there is no count, set it to 0
if (!count) {
count = 0;
}
// Increment the count
count++;
// Set the new count in redis
client.set('count', count);
// Log the new count
console.log(count);
}So, I actually consider this to be exactly the bad behavior that people accuse Copilot of.
// Create a redis client
Writing that probably takes a longer time than just doing it with the IDE help in jetbrains, though?Press "r", press "." to autocomplete so it now says "redis.", then write "cC" and it suggests createClient (or write "create" or "client" if you're not sure what you're looking for). Now it says "redis.createClient()". Press ctrl+alt+v to extract a variable or write ".const" and press tab to apply the const live template. Ending up with your result in two seconds.
+1 for the variable extraction thing, I've been using their IDE for ages and it never occurred to me to look for such a thing.