From 321ba3f949f1e9e39f5a73bba9bbca8739e62ecf Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Sun, 2 Jul 2023 13:02:59 -0700 Subject: track when suggestion is accepted or rejected --- extension/src/continueIdeClient.ts | 4 ++++ extension/src/suggestions.ts | 23 +++++++++-------------- 2 files changed, 13 insertions(+), 14 deletions(-) (limited to 'extension/src') diff --git a/extension/src/continueIdeClient.ts b/extension/src/continueIdeClient.ts index 21104abe..b39e6565 100644 --- a/extension/src/continueIdeClient.ts +++ b/extension/src/continueIdeClient.ts @@ -375,6 +375,10 @@ class IdeProtocolClient { sendCommandOutput(output: string) { this.messenger?.send("commandOutput", { output }); } + + sendAcceptRejectSuggestion(accepted: boolean) { + this.messenger?.send("acceptRejectSuggestion", { accepted }); + } } export default IdeProtocolClient; diff --git a/extension/src/suggestions.ts b/extension/src/suggestions.ts index baa49711..6e5a444f 100644 --- a/extension/src/suggestions.ts +++ b/extension/src/suggestions.ts @@ -5,7 +5,7 @@ import { translate, readFileAtRange } from "./util/vscode"; import * as fs from "fs"; import * as path from "path"; import { registerAllCodeLensProviders } from "./lang-server/codeLens"; -import { extensionContext } from "./activation/activate"; +import { extensionContext, ideProtocolClient } from "./activation/activate"; export interface SuggestionRanges { oldRange: vscode.Range; @@ -241,19 +241,14 @@ function selectSuggestion( suggestions = JSON.parse(rawData); } - if (accept === "new" || (accept === "selected" && suggestion.newSelected)) { - suggestions.push({ - accepted: true, - timestamp: Date.now(), - suggestion: suggestion.newContent, - }); - } else { - suggestions.push({ - accepted: false, - timestamp: Date.now(), - suggestion: suggestion.newContent, - }); - } + const accepted = + accept === "new" || (accept === "selected" && suggestion.newSelected); + suggestions.push({ + accepted, + timestamp: Date.now(), + suggestion: suggestion.newContent, + }); + ideProtocolClient.sendAcceptRejectSuggestion(accepted); // Write the updated suggestions back to the file fs.writeFileSync( -- cgit v1.2.3-70-g09d2