Merge pull request #85 from devchat-ai/fix_input_field_error

Enhance Non-Selection Behavior and Validate Selection Across Modules
This commit is contained in:
Tim 2024-04-01 19:04:41 +08:00 committed by GitHub
commit c1ce229c64
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 45 additions and 9 deletions

View File

@ -1,4 +1,3 @@
description: Automatically add doc comments. Select some code and execute this command to generate comments.
input: required
steps:
- run: $devchat_python $command_path/main.py

View File

@ -1,3 +1,4 @@
import os
import re
import sys
@ -21,7 +22,14 @@ def get_selected_code():
selected_data = IDEService().get_selected_range().dict()
miss_selected_error = "Please select some text."
if selected_data["text"] == "":
if selected_data["range"]["start"] == selected_data["range"]["end"]:
readme_path = os.path.join(os.path.dirname(__file__), "README.md")
if os.path.exists(readme_path):
with open(readme_path, "r", encoding="utf-8") as f:
readme_text = f.read()
print(readme_text)
sys.exit(0)
print(miss_selected_error, file=sys.stderr, flush=True)
sys.exit(-1)

View File

@ -1,4 +1,3 @@
description: Automatically add docstrings. Select a function or method and execute this command to generate docstring.
input: required
steps:
- run: $devchat_python $command_path/main.py

View File

@ -1,3 +1,4 @@
import os
import re
import sys
@ -21,7 +22,14 @@ def get_selected_code():
selected_data = IDEService().get_selected_range().dict()
miss_selected_error = "Please select some text."
if selected_data["text"] == "":
if selected_data["range"]["start"] == selected_data["range"]["end"]:
readme_path = os.path.join(os.path.dirname(__file__), "README.md")
if os.path.exists(readme_path):
with open(readme_path, "r", encoding="utf-8") as f:
readme_text = f.read()
print(readme_text)
sys.exit(0)
print(miss_selected_error, file=sys.stderr, flush=True)
sys.exit(-1)

View File

@ -1,4 +1,3 @@
description: Explain selected code.
input: required
steps:
- run: $devchat_python $command_path/explain.py

View File

@ -1,3 +1,4 @@
import os
import sys
from devchat.ide.service import IDEService
@ -19,7 +20,14 @@ def get_selected_code():
selected_data = IDEService().get_selected_range().dict()
miss_selected_error = "Please select some text."
if selected_data["text"] == "":
if selected_data["range"]["start"] == selected_data["range"]["end"]:
readme_path = os.path.join(os.path.dirname(__file__), "README.md")
if os.path.exists(readme_path):
with open(readme_path, "r", encoding="utf-8") as f:
readme_text = f.read()
print(readme_text)
sys.exit(0)
print(miss_selected_error, file=sys.stderr, flush=True)
sys.exit(-1)

View File

@ -1,4 +1,3 @@
description: Try to find out potential bugs in the selected code and try fixing these bugs automaticly.
input: required
steps:
- run: $devchat_python $command_path/main.py

View File

@ -1,3 +1,4 @@
import os
import re
import sys
@ -21,7 +22,14 @@ def get_selected_code():
selected_data = IDEService().get_selected_range().dict()
miss_selected_error = "Please select some text."
if selected_data["text"] == "":
if selected_data["range"]["start"] == selected_data["range"]["end"]:
readme_path = os.path.join(os.path.dirname(__file__), "README.md")
if os.path.exists(readme_path):
with open(readme_path, "r", encoding="utf-8") as f:
readme_text = f.read()
print(readme_text)
sys.exit(0)
print(miss_selected_error, file=sys.stderr, flush=True)
sys.exit(-1)

View File

@ -1,3 +1,4 @@
import os
import re
import sys
@ -21,7 +22,14 @@ def get_selected_code():
selected_data = IDEService().get_selected_range().dict()
miss_selected_error = "Please select some text."
if selected_data["text"] == "":
if selected_data["range"]["start"] == selected_data["range"]["end"]:
readme_path = os.path.join(os.path.dirname(__file__), "README.md")
if os.path.exists(readme_path):
with open(readme_path, "r", encoding="utf-8") as f:
readme_text = f.read()
print(readme_text)
sys.exit(0)
print(miss_selected_error, file=sys.stderr, flush=True)
sys.exit(-1)