summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--continuedev/src/continuedev/steps/core/core.py17
-rw-r--r--extension/src/lang-server/codeLens.ts16
-rw-r--r--extension/src/suggestions.ts9
3 files changed, 24 insertions, 18 deletions
diff --git a/continuedev/src/continuedev/steps/core/core.py b/continuedev/src/continuedev/steps/core/core.py
index 19ab5ec1..907ad9de 100644
--- a/continuedev/src/continuedev/steps/core/core.py
+++ b/continuedev/src/continuedev/steps/core/core.py
@@ -288,14 +288,11 @@ class DefaultModelEditCodeStep(Step):
current_line_in_file, 0, current_line_in_file, 0)), "#FFFFFF22" if len(current_block_lines) == 0 else "#FFFF0022")
if len(current_block_lines) == 0:
- if len(original_lines_below_previous_blocks) == 0 or line != original_lines_below_previous_blocks[0]:
- current_block_lines.append(line)
- current_block_start = current_line_in_file
-
- else:
+ current_block_start = current_line_in_file
+ if len(original_lines_below_previous_blocks) > 0 and line == original_lines_below_previous_blocks[0]:
original_lines_below_previous_blocks = original_lines_below_previous_blocks[
1:]
- return
+ return
# We are in a block currently, and checking for whether it should be ended
for i in range(len(original_lines_below_previous_blocks)):
@@ -303,12 +300,15 @@ class DefaultModelEditCodeStep(Step):
if og_line == line:
# Insert the suggestion
+ replacement = "\n".join(current_block_lines)
await sdk.ide.showSuggestion(FileEdit(
filepath=rif.filepath,
range=Range.from_shorthand(
current_block_start, 0, current_block_start + i, 0),
- replacement="\n".join(current_block_lines)
+ replacement=replacement
))
+ if replacement == "":
+ current_line_in_file += 1
# Reset current block / update variables
original_lines_below_previous_blocks = original_lines_below_previous_blocks[
@@ -348,6 +348,9 @@ class DefaultModelEditCodeStep(Step):
# Deal with newly accumulated lines
for line in chunk_lines:
+ # Trailing whitespace doesn't matter
+ line = line.rstrip()
+
# Lines that should signify the end of generation
if self.is_end_line(line):
break
diff --git a/extension/src/lang-server/codeLens.ts b/extension/src/lang-server/codeLens.ts
index 1f352797..5b55589c 100644
--- a/extension/src/lang-server/codeLens.ts
+++ b/extension/src/lang-server/codeLens.ts
@@ -6,12 +6,12 @@ class SuggestionsCodeLensProvider implements vscode.CodeLensProvider {
document: vscode.TextDocument,
token: vscode.CancellationToken
): vscode.CodeLens[] | Thenable<vscode.CodeLens[]> {
- let suggestions = editorToSuggestions.get(document.uri.toString());
+ const suggestions = editorToSuggestions.get(document.uri.toString());
if (!suggestions) {
return [];
}
- let codeLenses: vscode.CodeLens[] = [];
+ const codeLenses: vscode.CodeLens[] = [];
for (const suggestion of suggestions) {
const range = new vscode.Range(
suggestion.oldRange.start,
@@ -27,12 +27,16 @@ class SuggestionsCodeLensProvider implements vscode.CodeLensProvider {
title: "Reject ❌",
command: "continue.rejectSuggestion",
arguments: [suggestion],
- }),
- new vscode.CodeLens(range, {
- title: "(⌘⇧↩/⌘⇧⌫ to accept/reject all)",
- command: "",
})
);
+ if (codeLenses.length === 2) {
+ codeLenses.push(
+ new vscode.CodeLens(range, {
+ title: "(⌘⇧↩/⌘⇧⌫ to accept/reject all)",
+ command: "",
+ })
+ );
+ }
}
return codeLenses;
diff --git a/extension/src/suggestions.ts b/extension/src/suggestions.ts
index 209bf8b2..6e5f52ac 100644
--- a/extension/src/suggestions.ts
+++ b/extension/src/suggestions.ts
@@ -316,7 +316,7 @@ export async function showSuggestion(
(edit) => {
edit.insert(
new vscode.Position(range.end.line, 0),
- suggestion + "\n"
+ suggestion + (suggestion === "" ? "" : "\n")
);
},
{ undoStopBefore: false, undoStopAfter: false }
@@ -324,12 +324,11 @@ export async function showSuggestion(
.then(
(success) => {
if (success) {
+ const suggestionLinesLength =
+ suggestion === "" ? 0 : suggestion.split("\n").length;
let suggestionRange = new vscode.Range(
new vscode.Position(range.end.line, 0),
- new vscode.Position(
- range.end.line + suggestion.split("\n").length,
- 0
- )
+ new vscode.Position(range.end.line + suggestionLinesLength, 0)
);
const filename = editor!.document.uri.toString();