diff options
-rw-r--r-- | continuedev/src/continuedev/core/sdk.py | 2 | ||||
-rw-r--r-- | continuedev/src/continuedev/libs/util/dedent.py | 6 | ||||
-rw-r--r-- | continuedev/src/continuedev/steps/core/core.py | 7 |
3 files changed, 10 insertions, 5 deletions
diff --git a/continuedev/src/continuedev/core/sdk.py b/continuedev/src/continuedev/core/sdk.py index d95a233f..cfe2e436 100644 --- a/continuedev/src/continuedev/core/sdk.py +++ b/continuedev/src/continuedev/core/sdk.py @@ -199,7 +199,7 @@ class ContinueSDK(AbstractContinueSDK): # Don't insert after latest user message or function call i = -1 - if history_context[i].role == "user" or history_context[i].role == "function": + if len(history_context) > 0 and (history_context[i].role == "user" or history_context[i].role == "function"): i -= 1 history_context.insert(i, msg) diff --git a/continuedev/src/continuedev/libs/util/dedent.py b/continuedev/src/continuedev/libs/util/dedent.py index bbbeba5e..87876d4b 100644 --- a/continuedev/src/continuedev/libs/util/dedent.py +++ b/continuedev/src/continuedev/libs/util/dedent.py @@ -8,8 +8,14 @@ def dedent_and_get_common_whitespace(s: str) -> Tuple[str, str]: # Longest common whitespace prefix lcp = lines[0].split(lines[0].strip())[0] + # Iterate through the lines for i in range(1, len(lines)): + # Empty lines are wildcards + if lines[i].strip() == "": + continue + # Iterate through the leading whitespace characters of the current line for j in range(0, len(lcp)): + # If it doesn't have the same whitespace as lcp, then update lcp if j >= len(lines[i]) or lcp[j] != lines[i][j]: lcp = lcp[:j] if lcp == "": diff --git a/continuedev/src/continuedev/steps/core/core.py b/continuedev/src/continuedev/steps/core/core.py index f7b64a45..8f59bc4d 100644 --- a/continuedev/src/continuedev/steps/core/core.py +++ b/continuedev/src/continuedev/steps/core/core.py @@ -368,7 +368,7 @@ class DefaultModelEditCodeStep(Step): # Insert the suggestion replacement = "\n".join(current_block_lines) - start_line = current_block_start + 1 + start_line = current_block_start end_line = current_block_start + index_of_last_line_in_block await sdk.ide.showSuggestion(FileEdit( filepath=rif.filepath, @@ -376,10 +376,9 @@ class DefaultModelEditCodeStep(Step): start_line, 0, end_line, 0), replacement=replacement )) - if replacement == "": - current_line_in_file += 1 # Reset current block / update variables + current_line_in_file += 1 offset_from_blocks += len(current_block_lines) original_lines_below_previous_blocks = original_lines_below_previous_blocks[ index_of_last_line_in_block + 1:] @@ -501,7 +500,7 @@ class DefaultModelEditCodeStep(Step): await sdk.ide.showSuggestion(FileEdit( filepath=rif.filepath, range=Range.from_shorthand( - current_block_start + 1, 0, current_block_start + len(original_lines_below_previous_blocks), 0), + current_block_start, 0, current_block_start + len(original_lines_below_previous_blocks), 0), replacement="\n".join(current_block_lines) )) |