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:
commit
c1ce229c64
@ -1,4 +1,3 @@
|
|||||||
description: Automatically add doc comments. Select some code and execute this command to generate comments.
|
description: Automatically add doc comments. Select some code and execute this command to generate comments.
|
||||||
input: required
|
|
||||||
steps:
|
steps:
|
||||||
- run: $devchat_python $command_path/main.py
|
- run: $devchat_python $command_path/main.py
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import os
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
@ -21,7 +22,14 @@ def get_selected_code():
|
|||||||
selected_data = IDEService().get_selected_range().dict()
|
selected_data = IDEService().get_selected_range().dict()
|
||||||
|
|
||||||
miss_selected_error = "Please select some text."
|
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)
|
print(miss_selected_error, file=sys.stderr, flush=True)
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
description: Automatically add docstrings. Select a function or method and execute this command to generate docstring.
|
description: Automatically add docstrings. Select a function or method and execute this command to generate docstring.
|
||||||
input: required
|
|
||||||
steps:
|
steps:
|
||||||
- run: $devchat_python $command_path/main.py
|
- run: $devchat_python $command_path/main.py
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import os
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
@ -21,7 +22,14 @@ def get_selected_code():
|
|||||||
selected_data = IDEService().get_selected_range().dict()
|
selected_data = IDEService().get_selected_range().dict()
|
||||||
|
|
||||||
miss_selected_error = "Please select some text."
|
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)
|
print(miss_selected_error, file=sys.stderr, flush=True)
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
description: Explain selected code.
|
description: Explain selected code.
|
||||||
input: required
|
|
||||||
steps:
|
steps:
|
||||||
- run: $devchat_python $command_path/explain.py
|
- run: $devchat_python $command_path/explain.py
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from devchat.ide.service import IDEService
|
from devchat.ide.service import IDEService
|
||||||
@ -19,7 +20,14 @@ def get_selected_code():
|
|||||||
selected_data = IDEService().get_selected_range().dict()
|
selected_data = IDEService().get_selected_range().dict()
|
||||||
|
|
||||||
miss_selected_error = "Please select some text."
|
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)
|
print(miss_selected_error, file=sys.stderr, flush=True)
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
description: Try to find out potential bugs in the selected code and try fixing these bugs automaticly.
|
description: Try to find out potential bugs in the selected code and try fixing these bugs automaticly.
|
||||||
input: required
|
|
||||||
steps:
|
steps:
|
||||||
- run: $devchat_python $command_path/main.py
|
- run: $devchat_python $command_path/main.py
|
||||||
|
10
fix/main.py
10
fix/main.py
@ -1,3 +1,4 @@
|
|||||||
|
import os
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
@ -21,7 +22,14 @@ def get_selected_code():
|
|||||||
selected_data = IDEService().get_selected_range().dict()
|
selected_data = IDEService().get_selected_range().dict()
|
||||||
|
|
||||||
miss_selected_error = "Please select some text."
|
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)
|
print(miss_selected_error, file=sys.stderr, flush=True)
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import os
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
@ -21,7 +22,14 @@ def get_selected_code():
|
|||||||
selected_data = IDEService().get_selected_range().dict()
|
selected_data = IDEService().get_selected_range().dict()
|
||||||
|
|
||||||
miss_selected_error = "Please select some text."
|
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)
|
print(miss_selected_error, file=sys.stderr, flush=True)
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user