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:
parent
852706d25d
commit
5395639347
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user