-
Notifications
You must be signed in to change notification settings - Fork 477
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
[RFC] Switch to move/copy concept instead of yank/cut/paste #319
Comments
Disclaimer: I didn't try nnn. In the proposal, how do you tell whether your selection is finalized or not, under these scenarios:
|
@15cm what does it mean for selection(s) to be finalized? It seems to me that selections would always be "finalized" in the sense that at any moment the user could press a key to initiate |
I didn't realize that multiple selections are supported. I thought I have to select a region, yank, and then select another region. My question got resolved and I'd vote for the proposal as well. Some thoughts about the yank concept. In the GUI file managers we need ctrl-c or cmd-c to copy because the selection does not persists when you change the directory. However, the selection in Yazi persists until unselect and can serve as the clipboard by itself. I don't see the necessity of the yank clipboard either. The proposal is more like the DnD behavior in GUI FMs, where drop means copy and shift+drop means move. |
Yes, that’s it. You select as many files (and folders) across folders as you like, and when you are done you just perform a Currently yanking/coping from multiple source folders is not supported, and it might be confusing. This proposal would ‘just’ need to support cross folder selection. |
It seems to me that there could also be a |
Sounds quite appealing, I'm still considering its potential pros and cons. Since this is a proposal that could change user behavior, I'll be adding an RFC tag to see the community's opinion. |
I like the idea. Maybe along with that a window that allows to quickly see the selected files in a list would then also come in handy. |
This is a big one for me. |
I like this proposal a lot. Pasting the files in the location folder is much more intuitive. It doesn't deviate much from vim if you can just use p to put the file in the destination folder, right? Or maybe it can be put behind a config value, so both options are possible? I'm not sure what the maintenance burden will be since I'm only a Yazi user that doens't know the code. |
Sounds similar to how MC (Midnight Commander) does copying/moving. Though, its default mode is twin-panels… |
Do we need support for cross-directory operations? If so, I'd like to know more about its details - how does it work? Consider: I have selected |
That's a good question. nnn/cp for example will prompt
and copy the directories to If you mark I hope I got your questions right. |
Well, in the abstract sense, it'd make sense to simply copy/move all selected files/folders to the chosen destination (which would result in multiple copies of the same subtree when selected along with its parent for copying, and in the subtree being simply removed from the parent dir when selected for moving). Detecting subtree nesting would be a plus I suppose, though not exactly trivial considering possible existence of symlinks, hard links & bind-mounts. The case of name collisions is more complicated, but it could be handled similarly to collisions with already existing files during regular copying/moving operations; i.e. when copying/moving a directory on top of existing one, they get merged (with optional confirmation), and in other cases the result would be either replacing the existing file altogether, skipping, or aborting the operation. The only important difference is that when the user tries to move multiple identically-named files, the replacing approach would result in losing all but one of them (…which is technically still viable, but the confirmation request would need to be IN ALL CAPS in this case). …One way or another, it's probably a good idea to explicitly show the list which files/folders are going to be copied/moved to the user (possibly shortening long lists from the same source, e.g "…and 127 more from the same folder"), and/or all of the source folders (to avoid accidentally copying/moving unintended selection). |
Fully agreed. |
@LeXofLeviafan Ah yeah, this reminds me that we also need to consider the repetition of To handle these, we'll need to establish a basis in synchronous operations. However, Yazi's copy, cut, and delete are concurrent (which means that if we merge them, Maybe we can avoid users selecting potentially conflicting files in some way? For instance, displaying an error when ...There might be other better ways to handle this. I'm not sure what would be more intuitive; I haven't even used cross-directory file selection before :) |
…Can't the operations be enqueued to run sequentially for each selection (potentially grouped by folder)? I.e. when paths A, B and C are selected, and a ‘copy’ to D is requested, there will be 3 operations added to a queue (‘A -> D’, ‘B -> D’, ‘C -> D’), and invoked in that order, polling the queue after completion of each operation. This might complicate the implementation a bit, but it would also make the outcome predictable (the app just needs to confirm how to handle collisions in the first place – which is needed for single path operations as well). |
This requires introducing a queuing mechanism for the task system and allowing partial tasks to pause and wait for one or more tasks it depends on to complete before resuming. If we prioritize based on the outermost directory, and execute a copy operation:
And when any task on which a task depends fails, it won't be executed and should also be presented as a failure - this is somewhat counterintuitive; we might need to group interdependent tasks in a specific way, which can be very complex. |
It seems to me that if copying or moving For example, I tried this out in Mac's Finder, where I had
then selected While it does make more sense in a visual file manager like Finder (where you can expand folders without entering them), I think the result was still fairly intuitive. |
I've used several file managers: vifm, ranger, lf, joshuto, and I think the correct operation would be to copy and move only the given directory or/and file itself, not the entire complete path. So, if I select the following files and directories: /a/b/file.txt then I want to copy these to the /home/user/Data directory, then the result should look like this: home/user/Data/file.txt |
@Tweoss Basically agree. I'm just wondering if in this scenario there should be a way to indicate to the user that the outermost directory will be treated as the target. Maybe when the user selects both Does this seem reasonable, or are there any other suggestions? @og900aero If I select Just reminded by @asim215 on Discord, I thought of a tricky question we've never considered - how to handle multi-tabs? Currently, |
I think the colors make great sense! In the comparison to Mac's Finder, though, Finder only has a single blue selection color. This does lower the mental work to understand selections. I think, perhaps, one reason to have a single selection state is for operations that don't conflict like copying and moving do. Bulk renaming would be one such operation. Having colors, then, just distinguishes behavior for moving and copying. Other operations still use that selection. I did some more experimenting and "New Folder with Selection" first moves selected child folders out to the same level as the selected parent folders, then creates the new folder with the selection. This could be another possible solution (move or copy inner items to topmost level, then proceed with updated selection; equivalently, apply move/copy operations to inner items before outer items). Funnily enough, Finder produced a malformed archive when asked to archive a child folder / text file and its parent. I guess this shows how this is indeed a difficult problem we're trying to solve. I'm wondering if we could think of tabs as registers. I think that it would be most natural to have each tab with their independent selections; otherwise, we might have a "spooky action at a distance" situation where some selections in different tabs are red or green for non-obvious reasons. Additionally, pasting into, for example, tab 2 from selections in tab 1, 3, and 4 with a non-trivial merging heuristic would probably be very confusing. For those reasons, perhaps we could treat each tab as a register, and enable pasting from different tabs with some bindable command. By default, I can see how this register approach could add complexity to the mental model, so perhaps it is not the ideal approach. |
If you were to perform operations on the same location with files of the same name on different routes, then the current setup could remain, so { on = [ "p" ], exec = "paste", desc = "Paste the files" }, In other words, you copy to p by leaving the first one copied and renaming the next one, and to P the last file with the same name would overwrite the previous one. I do not support the introduction of different colors for files in different places. I think the different colors should be associated with actions. For example: In the case of selections made on different tabs, two solutions are possible:
Furthermore, I consider it important that if copying from different places to one place is realized, then there should be a function such that when the copy or cut operation is realized, the selections are automatically deleted after select, copy, cut. Otherwise, an action that we do not want may occur afterwards (deletion is an example). It would be good to link this action to a button, for example, because I have had many files selected for copying, but I changed my mind and wanted to delete the selection for copying, but I don't know, I can only delete the simple select action with ESC. The copy, cut mark is no longer there. I had to exit the program and then back in to get them deleted. |
It is not a good idea to issue different selections and actions on two different tabs of a file manager at the same time. This is specifically a very big mistake that can cause quite big problems. It is no coincidence that there is no known file manager that allows this. |
@og900aero Hmm, to the best of my knowledge, any file manager that supports multiple tabs behaves in this way. Whether it's a TUI or a GUI, they all allow operations independent of tabs and enable copying or moving files between tabs. I use it like this every day, and otherwise, I'm not sure what the purpose of having multiple tabs would be. |
Yeah. That's normal for copy or cut between tabs (example yank files on tab 1 and paste in tab 2), but not normal for yank files on tab 1 and cut files on tab 2 and select files on tab 3, and paste operation whatever tab, because in such cases it is not possible to clearly decide what the good solution is. This case is not supported by any known file manager. |
Thank you for all the feedback. I think it boils down to two concepts: 1) Select files/folders -> cd somewhere -> press Color coding etc. is a bit easier, see #319 (comment). 2) Select files/folders -> The bolded part is probably very important for most people, as mentioned in #319 (comment). In combination with #313 2) is probably what most people want, expect and are used to, even if coming from GUI file managers. (If -- in addition -- EDIT: Cross posting. I did not read your latest comments before posting this 😉 |
I think you've confused some concepts. Please take some time (perhaps around 10 minutes) to carefully read the content of this RFC and the discussion below. In short, Yazi is currently not exhibiting the behavior you described, nor is it heading in that direction. I don't want to provide further repetitive explanations here, sorry. |
Perfect summary! |
What about a poll ? |
There is no one right way to delete/copy/move files but I came here to see if vifm's method had been considered. In vifm d+d deletes selected file(s) and moves to a trash directory which can then be p to paste (move) or u to undo. Ultimately, it results with one very comfortable (to me) delete or move operation. Outside of the yazi's delete feature, I love what I am seeing. It a very nice file manager. |
My two cents: conflicts arising out of multi-direct selection need to be addressed anyway as they happen now also when selecting files from fd's output. Suppose we have files named |
The renaming scheme should be customizable, just like graphical file managers ask how to rename individual files in case of conflict. But any scheme would do imho. |
So, how about this proposal? Let's start with the simplest approach. This RFC covers too many aspects (abolishing yank, cross-level selection, multiple tabs, state synchronization, conflict resolution, custom renaming schemes), and there are conflicts between them, making it challenging to implement this RFC. |
This covers one important use-case for me: within the same tab, I would be able to select files from multiple directories, go to the destination directory, and only then decide whether to move/paste. |
I would like to second this -- despite the original proposal of this thread. |
Does anyone want to take on this task? |
Reading the whole thread, but especially this:
I wonder when yank (and copying?) is buried, can I no longer:
Sorry if I missed something... |
@rafo No, this proposal #319 (comment) does NOT abolish any existing functionality, it only enhances the current functionality by allowing cross-level selection, whereas the current selection only supports selection within the current working directory. So it won't affect your use case. |
Hi, I made a PR trying to implement this RFC, #693, let me know if it works for you! |
Wow! Thank you very, very much for your efforts. For me, your PR works perfectly. These things spontaneously come to my mind. (And please excuse, that I can only make some comments from a user’s perspective, but not contribute to your Rust code. I would love to …)
Thanks again. Yazi is just terrific! (Tested with 60df56b.) |
For me working fine! Thank u this support! |
Works great for me as well! Thank you very much for this feature! Like @Brixy mentioned, I feel y/d should add the current selection to the yank/cut queue, instead of replacing it. That would also make yanking/cutting files from different tabs possible. |
Thank you all for the test!
This is because the indicator on the left of the file list can only represent one state at a time, and the counter in the header also follows this approach to ensure consistency in behavior. There is some related discussion here: #682 (comment). Perhaps we can find a better way to optimize it in the future.
I think this is a bit too complex. Besides implementing nested selection conflict detection, we also need to implement a "nested yank conflict detection". I also haven't seen its use case - you can select all the necessary files in multiple directories by multiple times in batches and then yank them all at once, why do we need to yank them multiple times at each selection? |
I was thinking of the case when we yank some files and then realize that we forgot to include some files. Yes we can do the paste and then come back for the new files. But if we want to say do the copying/moving in a batch (e.g., because the files are big and the file transfers would take a bit), the ability to add to the yank/cut queue would be handy. But not a big deal by any means. |
I see your point. Yazi has a sophisticated scheduling system for copy and paste tasks, so you don't need to manually batch yank - paste these files. You can yank them all at once, let's say 10,000 files, and then paste them, and there won't be any issue. The scheduling system will add them to the queue and then execute them concurrently in order. |
I'm going to lock this issue because it has been closed for 30 days. ⏳ This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
Is your feature request related to a problem? Please describe
Hi guys!
This may be a far-reaching idea. If it does not fit, please just close this issue ;-)
Currently you can
yank
oryank --cut
single files or a selection of files. In the target directory youpaste
the files. This is probably how most TUI file managers work.Will you be willing to contribute this feature?
Sorry – I am not a Rust expert.
Describe the solution you'd like
nnn uses a different concept: You just select one or more file, and in the target directory you either move (
v
) or copy (p
) these files.This seems more efficient, and I could think of these advantages:
d
for example, it’s a bit hard to predict what yazi — and other file managers — will do. The proposed concept just knows two states: selected or unselected. Moving, deleting, and copying only refers to selected files.Possible disadvantages:
Currently if you want to cut and paste a single file you just need to press
x
andp
.With the proposed concept it would be<Space>
andp
. There wouldn’t be much difference.Describe alternatives you've considered
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: