Copy command silently no-ops; Move At crashes with NameError on open files
還沒有人認領這個 Issue。
評估
研究方向
閱讀 advanced_new_file/commands/copy_file_command.py 和 advanced_new_file/commands/move_file_command.py,比較它們的 _try_prompt_if_dest_exists 方法和 move_from_argument 路徑。重現關閉覆寫警告時的複製行為,以及來源檔案在分頁中開啟時的移動行為。複製在正常情況下能繼續,且 Move At 完成時沒有 NameError,即為完成。
由索引模型根據 Issue 內容生成。
描述
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.
- 主要語言
- Python
- 星號
- 834
- 分支
- 96
- PR 合併指標
- 30 天內沒有已合併 PR
環境準備
這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
SublimeText/AdvancedNewFile 的其他 Issue
-
enhancement
難度 4/5 3-5 天 新手友好度 35/100
SublimeText/AdvancedNewFile#196 · 1 個 reaction ·
-
enhancement
難度 4/5 3-5 天 新手友好度 45/100
SublimeText/AdvancedNewFile#195 ·
-
難度 3/5 1-2 天 新手友好度 35/100
SublimeText/AdvancedNewFile#193 ·
-
enhancement
難度 4/5 3-5 天 新手友好度 25/100
SublimeText/AdvancedNewFile#183 · 2 則留言 ·
-
難度 3/5 1-2 天 新手友好度 42/100
SublimeText/AdvancedNewFile#180 ·
查看 SublimeText/AdvancedNewFile 的全部 Issue
相似的 Issue
-
難度 1/5 1-3 小時 新手友好度 85/100
WLAN-Pi/wlanpi-profiler#341 ·
維護者通常 1 天內回覆
-
Memory leak: the shared `validation_aborted_error` keeps every traceback it is raised through可能已有人在做 @Fire162 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 78/100
graphql-python/graphql-core#287 ·
-
難度 2/5 1-3 小時 新手友好度 67/100
roman-corgi/ctc-dip#160 ·
維護者通常 1 天內回覆
-
type-bug
難度 2/5 1-3 小時 新手友好度 72/100
維護者通常 1 天內回覆
-
render_findings.py reads and writes in the host's default encoding, so findings.html breaks on a cp1252 Windows host可能已有人在做 @Aaqibhafeezkhan 今天認領。 未關閉bug good first issue mentored python size: XS up-for-grabs
難度 2/5 1-3 小時 新手友好度 75/100
dheerajjha/mcp-migrate#366 · 1 則留言 ·
維護者通常 1 天內回覆