Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Copy command silently no-ops; Move At crashes with NameError on open files

オープン 初心者向け
#211 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
90/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python
領域
desktop, devtools

調査の方向性

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
スター
833
フォーク
96
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

SublimeText/AdvancedNewFile のほかの issue

SublimeText/AdvancedNewFile の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。