diff options
author | Nate Sesti <sestinj@gmail.com> | 2023-06-27 23:20:15 -0700 |
---|---|---|
committer | Nate Sesti <sestinj@gmail.com> | 2023-06-27 23:20:15 -0700 |
commit | 18dbf82507f6b1c91581ea7e017e1e40ff479d1f (patch) | |
tree | 3ae3966ff96582b1807da2b06db15fa66d400355 | |
parent | a5a35a1edec3ee769e5e1b93fe1b9b1673059a9b (diff) | |
download | sncontinue-18dbf82507f6b1c91581ea7e017e1e40ff479d1f.tar.gz sncontinue-18dbf82507f6b1c91581ea7e017e1e40ff479d1f.tar.bz2 sncontinue-18dbf82507f6b1c91581ea7e017e1e40ff479d1f.zip |
backtrack lines at end after ending block
-rw-r--r-- | continuedev/src/continuedev/steps/core/core.py | 16 | ||||
-rw-r--r-- | extension/src/suggestions.ts | 16 |
2 files changed, 19 insertions, 13 deletions
diff --git a/continuedev/src/continuedev/steps/core/core.py b/continuedev/src/continuedev/steps/core/core.py index 16ca18a1..7d5d52b2 100644 --- a/continuedev/src/continuedev/steps/core/core.py +++ b/continuedev/src/continuedev/steps/core/core.py @@ -318,17 +318,20 @@ class DefaultModelEditCodeStep(Step): if matched_lines_at_end_of_block >= LINES_TO_MATCH_BEFORE_ENDING_BLOCK: # We've matched the required number of lines, insert suggestion! - # But first, remove the lines that were matched, because they shouldn't be a part of the block - # Remove matched_lines_at_end_of_block lines from current_block_lines - current_block_lines = current_block_lines[:- - matched_lines_at_end_of_block] + # We added some lines to the block that were matched (including maybe some blank lines) + # So here we will strip all matching lines from the end of current_block_lines + lines_stripped = [] + index_of_end_of_block = index_of_line_to_match + while len(current_block_lines) > 0 and current_block_lines[-1] == original_lines_below_previous_blocks[index_of_end_of_block - 1]: + lines_stripped.append(current_block_lines.pop()) + index_of_end_of_block -= 1 # 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 + index_of_last_matched_line, 0), + current_block_start, 0, current_block_start + index_of_end_of_block, 0), replacement=replacement )) if replacement == "": @@ -340,6 +343,9 @@ class DefaultModelEditCodeStep(Step): offset_from_blocks += len(current_block_lines) current_block_lines = [] current_block_start = -1 + matched_lines_at_end_of_block = 0 + index_of_last_matched_line = -1 + return else: matched_lines_at_end_of_block += 1 diff --git a/extension/src/suggestions.ts b/extension/src/suggestions.ts index 6e5f52ac..c9e29ed5 100644 --- a/extension/src/suggestions.ts +++ b/extension/src/suggestions.ts @@ -37,18 +37,18 @@ const oldDecorationType = vscode.window.createTextEditorDecorationType({ const newSelDecorationType = vscode.window.createTextEditorDecorationType({ backgroundColor: "rgb(0, 255, 0, 0.25)", isWholeLine: true, - after: { - contentText: "Press ctrl+shift+enter to accept", - margin: "0 0 0 1em", - }, + // after: { + // contentText: "Press ctrl+shift+enter to accept", + // margin: "0 0 0 1em", + // }, }); const oldSelDecorationType = vscode.window.createTextEditorDecorationType({ backgroundColor: "rgb(255, 0, 0, 0.25)", isWholeLine: true, - after: { - contentText: "Press ctrl+shift+enter to reject", - margin: "0 0 0 1em", - }, + // after: { + // contentText: "Press ctrl+shift+enter to reject", + // margin: "0 0 0 1em", + // }, }); export function rerenderDecorations(editorUri: string) { |