echasnovski / mini.nvim

Library of 40+ independent Lua modules improving overall Neovim (version 0.8 and higher) experience with minimal effort
MIT License
4.84k stars 183 forks source link

mini.files: file deletion upon undoing rename operation #656

Closed wroyca closed 8 months ago

wroyca commented 8 months ago

Contributing guidelines

Module(s)

files

Description

After renaming a file and confirming the change, attempting to undo and then reconfirming will result in the file being deleted. This has led to many issues in large-scale codebase refactoring, among others.

Neovim version

NVIM v0.10.0-dev+1974-g714b07519

Steps to reproduce

  1. Create two files, hello.c and hello.h.
  2. Rename hello.c to main.c and confirm the change.
  3. Undo the previous rename operation and confirm.
  4. Observe that our file is now deleted.

Expected behavior

Undoing a file rename should not result in file deletion; rather, main.c should revert to being hello.c.

Actual behavior

Screencast from 2024-01-15 11-54-09.webm

echasnovski commented 8 months ago

Thanks for the issue!

I can indeed confirm. The reason this happens is because of how 'mini.files' tracks which operation need to be done. Here is what is going on:

I'll see what is the best approach in this situation.

echasnovski commented 8 months ago

Thanks again for opening the issue! This should be fixed on latest main.

wroyca commented 8 months ago

Thanks again for opening the issue! This should be fixed on latest main.

I confirm, thank for the quick fix!