Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

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

Open Beginner friendly
#211 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
90/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
desktop, devtools

Research direction

Read advanced_new_file/commands/copy_file_command.py and advanced_new_file/commands/move_file_command.py, comparing their _try_prompt_if_dest_exists methods and the move_from_argument path. Reproduce the copy behavior with overwrite warnings off and the move behavior with the source open in a tab. Done when copying proceeds in the normal case and Move At completes without a NameError.

Written by the indexing model from the issue text.

Description

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.

Dominant language
Python
Stars
833
Forks
96
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from SublimeText/AdvancedNewFile

All issues in SublimeText/AdvancedNewFile

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.