Copy command silently no-ops; Move At crashes with NameError on open files
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 90/100
Hướng nghiên cứu
Đọc advanced_new_file/commands/copy_file_command.py và advanced_new_file/commands/move_file_command.py, so sánh các phương thức _try_prompt_if_dest_exists của chúng và luồng move_from_argument. Tái hiện hành vi sao chép khi tắt cảnh báo ghi đè và hành vi di chuyển khi tệp nguồn đang mở trong một tab. Hoàn thành khi việc sao chép tiếp tục trong trường hợp thông thường và Move At hoàn tất mà không có NameError.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Bug 1: AdvancedNewFileCopyCommand silently does nothing
_try_prompt_if_dest_exists in advanced_new_file/commands/copy_file_command.py has no fallback return:
def _try_prompt_if_dest_exists(self, target):
if self.settings.get(WARN_OVERWRITE_ON_COPY_SETTING, False):
if os.path.exists(target):
return sublime.ok_cancel_dialog(
target + " already exists. Copy will overwrite existing file. Continue?"
)
It implicitly returns None whenever warn_overwrite_on_copy is off (the default) or the target doesn't already exist — i.e. in almost every normal case. _copy_file then does:
if not self._try_prompt_if_dest_exists(path):
return (False, path)
Since not None is True, the copy is skipped unconditionally in that case. The visible symptom: the "Copy" input panel appears, you type a path, press enter, and nothing happens — no file is created, no error shown.
This has been present since the overwrite-warning feature was introduced in d4e1fc5 ("warn overwrite on copy command"). The sibling implementation in move_file_command.py's _try_prompt_if_dest_exists does this correctly (it has return True at the end) — copy_file_command.py's version is just missing that line.
Fix:
def _try_prompt_if_dest_exists(self, target):
if self.settings.get(WARN_OVERWRITE_ON_COPY_SETTING, False):
if os.path.exists(target):
return sublime.ok_cancel_dialog(
target + " already exists. Copy will overwrite existing file. Continue?"
)
return True
Bug 2: AdvancedNewFileMoveCommand.move_from_argument references an undefined window
In advanced_new_file/commands/move_file_command.py:
def move_from_argument(self, source, target):
file_view = self._find_open_file(source)
if file_view is not None:
self.view.run_command("save")
window.focus_view(file_view)
window.run_command("close")
...
window is never assigned in this method (every other method in the file does window = self.window first). This path is hit via "Move At" (sidebar context menu → Move) when the targeted file is also currently open in a tab, and raises NameError: name 'window' is not defined.
Fix: use self.window instead of the bare window in both places.
Happy to open a PR with both one-line fixes if that's useful.
- Ngôn ngữ chính
- Python
- Star
- 833
- Fork
- 96
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của SublimeText/AdvancedNewFile
-
enhancement
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
SublimeText/AdvancedNewFile#196 · 1 reaction ·
-
enhancement
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
SublimeText/AdvancedNewFile#195 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
SublimeText/AdvancedNewFile#193 ·
-
enhancement
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
SublimeText/AdvancedNewFile#183 · 2 bình luận ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 42/100
SublimeText/AdvancedNewFile#180 ·
Tất cả issue của SublimeText/AdvancedNewFile
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 73/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
Imbad0202/academic-research-skills#987 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Add date of request to the UIĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
-
Pull-through from gcr.io returns 500 when pulling using podman/buildahCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởIssue Triage-Needed
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
pulp/pulp_container#2581 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
ROCm/rocm-systems#13754 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày