diff options
author | Nate Sesti <sestinj@gmail.com> | 2023-07-09 14:31:54 -0700 |
---|---|---|
committer | Nate Sesti <sestinj@gmail.com> | 2023-07-09 14:31:54 -0700 |
commit | 20f4d07eb1d584569752e67c754951b7892e3e6b (patch) | |
tree | c2a209f18568793c5163bc80add3a5f22a642f16 /continuedev | |
parent | 5709c9ae003ededb520ee641cae8c8570d4c93af (diff) | |
download | sncontinue-20f4d07eb1d584569752e67c754951b7892e3e6b.tar.gz sncontinue-20f4d07eb1d584569752e67c754951b7892e3e6b.tar.bz2 sncontinue-20f4d07eb1d584569752e67c754951b7892e3e6b.zip |
edit at cursor
Diffstat (limited to 'continuedev')
-rw-r--r-- | continuedev/src/continuedev/steps/main.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/continuedev/src/continuedev/steps/main.py b/continuedev/src/continuedev/steps/main.py index 0a20ddd7..4f543022 100644 --- a/continuedev/src/continuedev/steps/main.py +++ b/continuedev/src/continuedev/steps/main.py @@ -245,6 +245,17 @@ class EditHighlightedCodeStep(Step): async def run(self, sdk: ContinueSDK) -> Coroutine[Observation, None, None]: range_in_files = sdk.get_code_context(only_editing=True) + + # If nothing highlighted, insert at the cursor if possible + if len(range_in_files) == 0: + highlighted_code = await sdk.ide.getHighlightedCode() + if highlighted_code is not None: + for rif in highlighted_code: + if rif.range.start == rif.range.end: + range_in_files.append( + RangeInFileWithContents.from_range_in_file(rif, "")) + + # If nothing highlighted, edit the first open file if len(range_in_files) == 0: # Get the full contents of all open files files = await sdk.ide.getOpenFiles() |