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
-
comp/tools P2 type/bug
难度 2/5 1-3 小时 新手友好度 78/100
NousResearch/hermes-agent#142908 · 1 条评论 ·
-
[oblt-aw][autodoc] Fix malformed headings in new Buildkite docs pages可能已有人在做 @github-actions 今天认领。 未关闭documentation
难度 1/5 1 小时以内 新手友好度 83/100
维护者通常 1 天内回复
-
[Bug]: fileUploadMatrix.test.ts URL case does a real DNS lookup and fails offline可能已有人在做 @r2jaff 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
ComposioHQ/composio#5054 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 88/100
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 82/100
pytorch/tensordict#3286 ·
维护者通常 1 天内回复