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

Focus cursor on the file after moving it to a target dir #1950

Closed
2 of 3 tasks
exquo opened this issue Nov 25, 2024 · 5 comments
Closed
2 of 3 tasks

Focus cursor on the file after moving it to a target dir #1950

exquo opened this issue Nov 25, 2024 · 5 comments
Labels
invalid This doesn't seem right

Comments

@exquo
Copy link

exquo commented Nov 25, 2024

yazi --debug output

n/a

Please describe the problem you're trying to solve

After moving a file to a new location (focusing the cursor on the file, pressing x, then navigating to a different directory, and pressing p), the cursor will still be on the first file in the directory. In some situations, it would be helpful if the focus was placed on the file being moved.

Would you be willing to contribute this feature?

  • Yes, I'll give it a shot

Describe the solution you'd like

After pressing p the focus / cursor is placed on the new file.

Additional context

This is useful when some additional action with the moved file needs to be taken. For example, when xdg-desktop-portal-termfilechooser uses yazi (with --chooser-file argument) to save a file, it is often necessary to first move the file to a different location, after which the file is selected (with Enter), its path is then passed to termfilchooser, and the file is saved at that path.
With the current situation, after moving the file (pressing p), it is necessary to find the new file among all the other files already in the dir, put the cursor on it, and press Enter. Depending on how many files are already in the dir, and how distinctively the new file is named, this might be not effortless.

Perhaps there could be a switch / argument for it. Or it could be automatically enabled when --chooser-file is active. But offhand it seems like this might be convenient even enabled by default.

Somewhat relevant: #1136 for other suggestions to making yazi more convenient to use with termfilechooser.

Related in case this is advised to be implemented with a plugin: #1713 (comment) Tips on p action code.

Validations

  • I have searched the existing issues/discussions
  • The latest nightly build doesn't already have this feature
@exquo exquo added the feature New feature request label Nov 25, 2024
@sxyazi
Copy link
Owner

sxyazi commented Nov 25, 2024

Duplicate of #1706

@sxyazi sxyazi closed this as not planned Won't fix, can't repro, duplicate, stale Nov 25, 2024
@sxyazi sxyazi added invalid This doesn't seem right and removed feature New feature request labels Nov 25, 2024
@exquo
Copy link
Author

exquo commented Nov 25, 2024

Ah, I used different keywords when searching through the existing issues. Thanks!

@exquo
Copy link
Author

exquo commented Nov 25, 2024

Since the linked conversation appears to be locked, I'll ask here:

Would the following work?
After pressing p, an emtpty file is immediately created and the cursor / focus is placed on it. Then yazi (asynchronously) copies / movies the contents of the file.
There might be potential problems if performing certain actions on the file while it is still being copied (e.g. d should abort the ongoing copy, etc)

@sxyazi
Copy link
Owner

sxyazi commented Nov 25, 2024

Can you explain your proposal in more detail? For example, are you suggesting creating it in Yazi's file system (file list) or actually creating it on the operating system's file system? How would cutting and copying work in each case? What happens if the creation of a new file fails? What if the file is created successfully, but copying or cutting fails? When dealing with multiple files, how would copying and cutting work? Would it create only the first file or all of them?

@exquo
Copy link
Author

exquo commented Nov 26, 2024

This is indeed a not-so-straightforward area of operating on partially transferred files. I don't know the internal mechanics of yazi, but from a UX perspective yazi appears to already have this type of user interaction:

When copying a large file or directory to a new location, the new file shows up while the transfer is still in progress. I propose to simply place the focus / cursor on the new file. So, to answer your first question: whatever way yazi currently handles partially-transferred files would be preserved, the only difference is that the focus would be on the new file right away.

In situations when yazi would remove the new file from the listing, due to e.g. unsuccessful transfer, the cursor could be moved to another file, e.g. returned to the position before the transfer start. This however might cause some UX issues if the user was in the middle of an attempt to perform an action on the new file (e.g. trying to delete it by pressing d), as now the action would be applied to the file the focus has jumped to. To overcome this kind of issue, one solution might be to not remove the file from the listing until the user manually moves focus to a different file.

When transferring multiple files, any reasonable option would be fine for the purposes of this issue. For instance, placing it on the first file that has started the transfer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants