Merge branch 'main' of https://github.com/continuedev/continue
This commit is contained in:
commit
d7d9e445df
3 changed files with 55 additions and 1 deletions
|
|
@ -62,6 +62,11 @@
|
|||
"type": "password",
|
||||
"default": "",
|
||||
"description": "The Hugging Face API token to use for code generation."
|
||||
},
|
||||
"continue.dataSwitch": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "If true, collect data on accepted and rejected suggestions."
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -231,6 +231,7 @@ export function setupDebugPanel(
|
|||
apiUrl: getContinueServerUrl(),
|
||||
sessionId,
|
||||
vscMediaUrl,
|
||||
dataSwitchOn: vscode.workspace.getConfiguration("continue").get<boolean>("dataSwitch")
|
||||
});
|
||||
|
||||
// // Listen for changes to server URL in settings
|
||||
|
|
@ -247,7 +248,13 @@ export function setupDebugPanel(
|
|||
|
||||
break;
|
||||
}
|
||||
|
||||
case "toggleDataSwitch": {
|
||||
// Set the setting in vscode
|
||||
await vscode.workspace
|
||||
.getConfiguration("continue")
|
||||
.update("dataSwitch", data.on, vscode.ConfigurationTarget.Global);
|
||||
break;
|
||||
}
|
||||
case "websocketForwardingOpen": {
|
||||
let url = data.url;
|
||||
if (typeof websocketConnections[url] === "undefined") {
|
||||
|
|
|
|||
|
|
@ -2,11 +2,15 @@ import * as vscode from "vscode";
|
|||
import { sendTelemetryEvent, TelemetryEvent } from "./telemetry";
|
||||
import { openEditorAndRevealRange } from "./util/vscode";
|
||||
import { translate, readFileAtRange } from "./util/vscode";
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
|
||||
|
||||
export interface SuggestionRanges {
|
||||
oldRange: vscode.Range;
|
||||
newRange: vscode.Range;
|
||||
newSelected: boolean;
|
||||
newContent: string;
|
||||
}
|
||||
|
||||
/* Keyed by editor.document.uri.toString() */
|
||||
|
|
@ -204,6 +208,41 @@ function selectSuggestion(
|
|||
: suggestion.newRange;
|
||||
}
|
||||
|
||||
let workspaceDir = vscode.workspace.workspaceFolders ? vscode.workspace.workspaceFolders[0]?.uri.fsPath : undefined;
|
||||
|
||||
let collectOn = vscode.workspace.getConfiguration("continue").get<boolean>("dataSwitch")
|
||||
|
||||
if (workspaceDir && collectOn) {
|
||||
|
||||
let continueDir = path.join(workspaceDir, ".continue");
|
||||
|
||||
// Check if .continue directory doesn't exists
|
||||
if(!fs.existsSync(continueDir)) {
|
||||
fs.mkdirSync(continueDir);
|
||||
}
|
||||
|
||||
let suggestionsPath = path.join(continueDir, "suggestions.json");
|
||||
|
||||
// Initialize suggestions list
|
||||
let suggestions = [];
|
||||
|
||||
// Check if suggestions.json exists
|
||||
if(fs.existsSync(suggestionsPath)) {
|
||||
let rawData = fs.readFileSync(suggestionsPath, 'utf-8');
|
||||
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 });
|
||||
}
|
||||
|
||||
// Write the updated suggestions back to the file
|
||||
fs.writeFileSync(suggestionsPath, JSON.stringify(suggestions, null, 4), 'utf-8');
|
||||
|
||||
}
|
||||
|
||||
rangeToDelete = new vscode.Range(
|
||||
rangeToDelete.start,
|
||||
new vscode.Position(rangeToDelete.end.line, 0)
|
||||
|
|
@ -332,6 +371,7 @@ export async function showSuggestion(
|
|||
new vscode.Position(range.end.line, 0),
|
||||
new vscode.Position(range.end.line + suggestionLinesLength, 0)
|
||||
);
|
||||
let content = editor!.document.getText(suggestionRange);
|
||||
|
||||
const filename = editor!.document.uri.toString();
|
||||
if (editorToSuggestions.has(filename)) {
|
||||
|
|
@ -340,6 +380,7 @@ export async function showSuggestion(
|
|||
oldRange: range,
|
||||
newRange: suggestionRange,
|
||||
newSelected: true,
|
||||
newContent: content
|
||||
});
|
||||
editorToSuggestions.set(filename, suggestions);
|
||||
currentSuggestion.set(filename, suggestions.length - 1);
|
||||
|
|
@ -349,6 +390,7 @@ export async function showSuggestion(
|
|||
oldRange: range,
|
||||
newRange: suggestionRange,
|
||||
newSelected: true,
|
||||
newContent: content
|
||||
},
|
||||
]);
|
||||
currentSuggestion.set(filename, 0);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue