Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

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

Abierto Apto para principiantes
#211 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
90/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
python
Área
desktop, devtools

Línea de trabajo

Lee advanced_new_file/commands/copy_file_command.py y advanced_new_file/commands/move_file_command.py, comparando sus métodos _try_prompt_if_dest_exists y la ruta move_from_argument. Reproduce el comportamiento de copia con las advertencias de sobrescritura desactivadas y el comportamiento de movimiento con el archivo de origen abierto en una pestaña. Se considera terminado cuando la copia continúa en el caso normal y Move At se completa sin NameError.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Python
Estrellas
833
Forks
96
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de SublimeText/AdvancedNewFile

Todos los issues de SublimeText/AdvancedNewFile

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.