diff options
author | Nate Sesti <sestinj@gmail.com> | 2023-07-11 00:58:39 -0700 |
---|---|---|
committer | Nate Sesti <sestinj@gmail.com> | 2023-07-11 00:58:39 -0700 |
commit | bbda840cb7d79679a4b4a0de136708181d6c8de6 (patch) | |
tree | 04eb1dd723bbfd049183a7520706d17a6919e623 /continuedev | |
parent | 4b215f5fa19ebd0a4e49dec1e7b2bc3f376ddd15 (diff) | |
download | sncontinue-bbda840cb7d79679a4b4a0de136708181d6c8de6.tar.gz sncontinue-bbda840cb7d79679a4b4a0de136708181d6c8de6.tar.bz2 sncontinue-bbda840cb7d79679a4b4a0de136708181d6c8de6.zip |
raise error if no code selected to edit
Diffstat (limited to 'continuedev')
-rw-r--r-- | continuedev/src/continuedev/steps/main.py | 20 |
1 files changed, 3 insertions, 17 deletions
diff --git a/continuedev/src/continuedev/steps/main.py b/continuedev/src/continuedev/steps/main.py index 2a8cd250..e6ef9281 100644 --- a/continuedev/src/continuedev/steps/main.py +++ b/continuedev/src/continuedev/steps/main.py @@ -258,24 +258,10 @@ class EditHighlightedCodeStep(Step): range_in_files.append( RangeInFileWithContents.from_range_in_file(rif, "")) - # If nothing highlighted, edit the first open file + # If still no highlighted code, raise error if len(range_in_files) == 0: - # Get the full contents of all open files - files = await sdk.ide.getOpenFiles() - contents = {} - for file in files: - contents[file] = await sdk.ide.readFile(file) - - range_in_files = [RangeInFileWithContents.from_entire_file( - filepath, content) for filepath, content in contents.items()] - - # If still no highlighted code, create a new file and edit there - if len(range_in_files) == 0: - # Create a new file - new_file_path = "new_file.txt" - await sdk.add_file(new_file_path, "") - range_in_files = [ - RangeInFileWithContents.from_entire_file(new_file_path, "")] + raise ContinueCustomException( + message="Please highlight some code and try again.", title="No Code Selected") range_in_files = list(map(lambda x: RangeInFile( filepath=x.filepath, range=x.range |