Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Move file command does not work when destination folder contains file with same name #260

Closed
1 task done
isdmg opened this issue Oct 17, 2024 · 6 comments
Closed
1 task done
Assignees
Labels
bug Something isn't working

Comments

@isdmg
Copy link

isdmg commented Oct 17, 2024

Check for Commonly Missed Points

  • Files not shown in the suggestions are not an active file. (An active file is not shown in the suggestions.)

Summary

The Move file to another folder command does not work when the destination folder contains a file with the same name as the current file.

Steps to Reproduce in the Sandbox Vault

Assume that we have the following file structure:

folder1/
└── same-name.md
folder2/
└── same-name.md

If we run the Move file to another folder command on same-name.md in folder1 and choose the destination folder to be folder2, we get the following error in the developer console:

Uncaught (in promise) Error: Destination file already exists!
    at e.<anonymous> (app.js:1:536060)
    at app.js:1:237228
    at Object.next (app.js:1:237333)
    at a (app.js:1:236051)

Expected Behavior

The native Obsidian command Move current file to another folder moves the current file by appending a numerical value on the file name.

I expect the Move file to another folder command to copy the behavior of Move current file to another folder of Obsidian:

Before the command
folder1/
└── same-name.md
folder2/
└── same-name.md

After the command
folder1/
└── (EMPTY)
folder2/
├── same-name.md
└── same-name 1.md

Actual Behavior

Currently, the plugin does not work as expected. If we run the Move file to another folder command on same-name.md in folder1 and choose the destination folder to be folder2, we get this behavior:

Before the command
folder1/
└── same-name.md
folder2/
└── same-name.md

After the command
folder1/
└── same-name.md
folder2/
└── same-name.md

Obsidian Version

1.7.4

Another Quick Switcher Version

12.0.1

OS

Windows

Notes

No response

@tadashi-aikawa
Copy link
Owner

Thank you for the bug report, @isdmg :)

@tadashi-aikawa
Copy link
Owner

@isdmg
I attempted to fix this issue, but I just received an interesting post.

#261

I hadn’t been aware of it, but it seems that Obsidian now has a similar command as a core feature. Since you're using a similar command in Another Quick Switcher, I'd like to hear your thoughts on this: Do you think the Obsidian core feature can fully replace it?

@isdmg
Copy link
Author

isdmg commented Nov 9, 2024

@tadashi-aikawa
Yes. The core feature fully replaces the command in Another Quick Switcher. However, I like using the Another Quick Switcher command because you have the option to not display the full path of the directory, which is helpful for deeply nested folders.

I also believe it's safe to delete this command. And the issue that I opened isn't really that big of deal for me. You can do what you think is best for the plugin. I'll still use it even without the move file command feature :)

@tadashi-aikawa
Copy link
Owner

@isdmg
Thank you for the helpful response! As you pointed out, there are indeed display differences. I believe which feature to use is up to the user, so I’ll keep this command as it is. 👍

@tadashi-aikawa tadashi-aikawa moved this from Todo to In Progress in Obsidian Another Quick Switcher Plugin Nov 9, 2024
@tadashi-aikawa
Copy link
Owner

When paths conflict, I've modified it to append a timestamp-based suffix instead of a sequential number. Additionally, a dot is used instead of whitespace.

image

tadashi-aikawa added a commit that referenced this issue Nov 9, 2024
@tadashi-aikawa tadashi-aikawa moved this from In Progress to Done in Obsidian Another Quick Switcher Plugin Nov 9, 2024
github-actions bot pushed a commit that referenced this issue Nov 9, 2024
## [12.1.0](12.0.1...12.1.0) (2024-11-09)

### ✨ Features

* **main:** Add a 'close if opened' hotkey command ([#256](#256)) ([9705517](9705517))
* **main:** Auto alias transform ([#262](#262)) ([c526ad8](c526ad8))

### 🛡 Bug Fixes

* **move:** Move file command does not work when destination folder contains file with same name ([#260](#260)) ([fd6f95c](fd6f95c))
@tadashi-aikawa
Copy link
Owner

@isdmg
Released in v12.1.0 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

2 participants