fix: Improve selection validation logic across modules

- Changed the condition to determine selection absence by comparing start and end range instead of checking if text is empty.
- Ensures that a non-selection (where start and end range are the same) correctly triggers the absence of selection error.
- Applied this logic uniformly in comments, docstring, explain, fix, and refactor modules.
This commit is contained in:
bobo 2024-04-01 16:46:47 +08:00
parent 852706d25d
commit 5395639347
5 changed files with 5 additions and 5 deletions

View File

@ -23,7 +23,7 @@ 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:

View File

@ -22,7 +22,7 @@ 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:

View File

@ -20,7 +20,7 @@ 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:

View File

@ -22,7 +22,7 @@ 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:

View File

@ -22,7 +22,7 @@ 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: