summaryrefslogtreecommitdiff
path: root/extension
diff options
context:
space:
mode:
authorNate Sesti <sestinj@gmail.com>2023-06-27 00:20:56 -0700
committerNate Sesti <sestinj@gmail.com>2023-06-27 00:20:56 -0700
commit21110bb7277b09a40b367d336f9eb318a874426e (patch)
tree8543d08b780c0e1661ab123a59456868d6d9e1e8 /extension
parenta46f753f8c1245a0954c301a586b69889fc366db (diff)
downloadsncontinue-21110bb7277b09a40b367d336f9eb318a874426e.tar.gz
sncontinue-21110bb7277b09a40b367d336f9eb318a874426e.tar.bz2
sncontinue-21110bb7277b09a40b367d336f9eb318a874426e.zip
checkpoint on new streaming
Diffstat (limited to 'extension')
-rw-r--r--extension/src/activation/environmentSetup.ts6
-rw-r--r--extension/src/continueIdeClient.ts6
-rw-r--r--extension/src/lang-server/codeLens.ts4
-rw-r--r--extension/src/suggestions.ts52
4 files changed, 50 insertions, 18 deletions
diff --git a/extension/src/activation/environmentSetup.ts b/extension/src/activation/environmentSetup.ts
index 593b727e..cdaf3ac0 100644
--- a/extension/src/activation/environmentSetup.ts
+++ b/extension/src/activation/environmentSetup.ts
@@ -121,7 +121,7 @@ async function setupPythonEnv() {
activateCmd,
pipUpgradeCmd,
`${pipCmd} install -r requirements.txt`,
- ].join(" && ");
+ ].join(" ; ");
const [, stderr] = await runCommand(installRequirementsCommand);
if (stderr) {
throw new Error(stderr);
@@ -255,10 +255,10 @@ export async function downloadPython3() {
throw new Error("python3 not found");
} else if (os === "linux") {
command =
- "sudo apt update && upgrade && sudo apt install python3 python3-pip";
+ "sudo apt update ; upgrade ; sudo apt install python3 python3-pip";
} else if (os === "win32") {
command =
- "wget -O python_installer.exe https://www.python.org/ftp/python/3.11.3/python-3.11.3-amd64.exe && python_installer.exe /quiet InstallAllUsers=1 PrependPath=1 Include_test=0";
+ "wget -O python_installer.exe https://www.python.org/ftp/python/3.11.3/python-3.11.3-amd64.exe ; python_installer.exe /quiet InstallAllUsers=1 PrependPath=1 Include_test=0";
pythonCmd = "python";
}
diff --git a/extension/src/continueIdeClient.ts b/extension/src/continueIdeClient.ts
index b1fcd6fb..877d9f3e 100644
--- a/extension/src/continueIdeClient.ts
+++ b/extension/src/continueIdeClient.ts
@@ -145,6 +145,7 @@ class IdeProtocolClient {
// ------------------------------------ //
// On message handlers
+ private _lastDecorationType: vscode.TextEditorDecorationType | null = null;
async highlightCode(rangeInFile: RangeInFile, color: string) {
const range = new vscode.Range(
rangeInFile.range.start.line,
@@ -172,6 +173,11 @@ class IdeProtocolClient {
}
}
);
+
+ if (this._lastDecorationType) {
+ editor.setDecorations(this._lastDecorationType, []);
+ }
+ this._lastDecorationType = decorationType;
}
}
diff --git a/extension/src/lang-server/codeLens.ts b/extension/src/lang-server/codeLens.ts
index e8766c3c..3979b64d 100644
--- a/extension/src/lang-server/codeLens.ts
+++ b/extension/src/lang-server/codeLens.ts
@@ -20,12 +20,12 @@ class SuggestionsCodeLensProvider implements vscode.CodeLensProvider {
);
codeLenses.push(
new vscode.CodeLens(range, {
- title: "Accept",
+ title: "Accept ✅",
command: "continue.acceptSuggestion",
arguments: [suggestion],
}),
new vscode.CodeLens(range, {
- title: "Reject",
+ title: "Reject ❌",
command: "continue.rejectSuggestion",
arguments: [suggestion],
})
diff --git a/extension/src/suggestions.ts b/extension/src/suggestions.ts
index 2e4e0ea2..9b358899 100644
--- a/extension/src/suggestions.ts
+++ b/extension/src/suggestions.ts
@@ -59,10 +59,35 @@ export function rerenderDecorations(editorUri: string) {
);
if (!suggestions || !editor) return;
- const olds: vscode.Range[] = [];
- const news: vscode.Range[] = [];
- const oldSels: vscode.Range[] = [];
- const newSels: vscode.Range[] = [];
+ const rangesWithoutEmptyLastLine = (ranges: vscode.Range[]) => {
+ const newRanges: vscode.Range[] = [];
+ for (let i = 0; i < ranges.length; i++) {
+ const range = ranges[i];
+ if (
+ range.start.line === range.end.line &&
+ range.start.character === 0 &&
+ range.end.character === 0
+ ) {
+ // Empty range, don't show it
+ continue;
+ }
+ newRanges.push(
+ new vscode.Range(
+ range.start.line,
+ range.start.character,
+ // Don't include the last line if it is empty
+ range.end.line - (range.end.character === 0 ? 1 : 0),
+ range.end.character
+ )
+ );
+ }
+ return newRanges;
+ };
+
+ let olds: vscode.Range[] = [];
+ let news: vscode.Range[] = [];
+ let oldSels: vscode.Range[] = [];
+ let newSels: vscode.Range[] = [];
for (let i = 0; i < suggestions.length; i++) {
const suggestion = suggestions[i];
if (typeof idx != "undefined" && idx === i) {
@@ -78,6 +103,13 @@ export function rerenderDecorations(editorUri: string) {
news.push(suggestion.newRange);
}
}
+
+ // Don't highlight the last line if it is empty
+ olds = rangesWithoutEmptyLastLine(olds);
+ news = rangesWithoutEmptyLastLine(news);
+ oldSels = rangesWithoutEmptyLastLine(oldSels);
+ newSels = rangesWithoutEmptyLastLine(newSels);
+
editor.setDecorations(oldDecorationType, olds);
editor.setDecorations(newDecorationType, news);
editor.setDecorations(oldSelDecorationType, oldSels);
@@ -174,7 +206,7 @@ function selectSuggestion(
rangeToDelete = new vscode.Range(
rangeToDelete.start,
- new vscode.Position(rangeToDelete.end.line + 1, 0)
+ new vscode.Position(rangeToDelete.end.line, 0)
);
editor.edit((edit) => {
edit.delete(rangeToDelete);
@@ -261,19 +293,13 @@ export async function showSuggestion(
return new Promise((resolve, reject) => {
editor!
.edit((edit) => {
- if (range.end.line + 1 >= editor.document.lineCount) {
- suggestion = "\n" + suggestion;
- }
- edit.insert(
- new vscode.Position(range.end.line + 1, 0),
- suggestion + "\n"
- );
+ edit.insert(new vscode.Position(range.end.line, 0), suggestion + "\n");
})
.then(
(success) => {
if (success) {
let suggestionRange = new vscode.Range(
- new vscode.Position(range.end.line + 1, 0),
+ new vscode.Position(range.end.line, 0),
new vscode.Position(
range.end.line + suggestion.split("\n").length,
0