rgieseke / textredux

Text-based interfaces for Textadept
http://rgieseke.github.io/textredux/
Other
59 stars 11 forks source link

Fix save_buffer_as #57

Closed ghost closed 4 years ago

ghost commented 4 years ago
rgieseke commented 4 years ago

Thanks!

Can you elaborate on the 'right' key to force a callback?

And change the button texts to "Overwrite" and "Cancel"?

I know i've argued against more dialogs before, but maybe it's better to always have a confirmation dialog?

ghost commented 4 years ago

Can you elaborate on the 'right' key to force a callback?

Imagine the following: You want to save a file but the fuzzy matching interferes and you can only select an already existing file with a similar name. However you want to save your current file as the name you chose.
Example:

There is a file called foo and you want to save your current file as fo If you press ENTER then you will get a prompt to overwrite the file but you don't want that. So to force the current file being saved as fo you invoke the callback by pressing RIGHT.

Not sure I understand the need for always having a confirmation dialog, could you explain further? Do note that "Cancel" is the default selection, making it impossible to accidentally overwrite files. That decision has to be made conciously.

rgieseke commented 4 years ago

Ah right, i remember ...

There is a file called foo and you want to save your current file as fo I think this was one of the problems why i disabled "save as" back then.

This can be hard to discover for a user. What about having a message box with

[Save as fo] [Overwrite foo] [Cancel]

This also what i meant with the confirmation dialog, maybe there should always be a confirmation.

ghost commented 4 years ago

This can be hard to discover for a user.

Hmm true, always got to assume the worst. There is the statusbar description but we have to assume no one reads that either.

I'll look into adding it as another choice to the dialog.

ghost commented 4 years ago

This is a first draft of using the dialog instead of a keybind for saving with a custom name.
Things to consider

Let me know what you think.

rgieseke commented 4 years ago

I played with this and i think a better solution could be to insert the user_input into the current list (and then have a confirmation dialog). Not sure how easy or difficult to do (and don't remember if we discussed this solution before).

rgieseke commented 4 years ago

I tried to get something working last night but i think the key problem is that "save as" by default works by giving you name and then typically the user adds a _ver2 or backup to it. Not sure whether this is possible right now with Textredux.`

ghost commented 4 years ago

Do you have the code from your experiments somewhere for me to look at?

How do you want to proceed with this if your latest idea is not feasible?

rgieseke commented 4 years ago

I tried starting from the M.select_file but didn't get very far. I'm not sure how to proceed. With save_as it's crucial that it doesn't behave in any way unexpectedly for a user, as they might lose data ...

ghost commented 4 years ago

I actually like the solution you proposed first with the dialog. It's pretty safe too because the "dangerous" options have to be explicitly selected.
OTOH I think adding the user input to the list is hard to implement and not very intuitive or safe.

rgieseke commented 4 years ago

Ok, then let's try to sort this out! Maybe one still needs to consider the "on_new_selection" callback separately.

ghost commented 4 years ago

Do you have something specific in mind?
As I see it the current behavior is acceptable. The button being empty if there is no user input is admittedly not very nice though. Button now only shows up when the user entered something.

rgieseke commented 4 years ago

Ah, i hadn't got a notification (edits probably don't trigger this) - this looks promising!

rgieseke commented 4 years ago

One issue: if you have a folder foo, you can't save a file as fo because it will switch into foo on enter.

ghost commented 4 years ago

That's a direct cause of abandoning the keybind.
There is no way of knowing if the user wants to enter the folder or save as the current filename. The keybind from the original solution sidesteps that by always invoking the callback.
I do like the current version with the dialog but I see no good way to work around that issue.

OTOH I do think that TR would greatly benefit from having a "native" save_as function. I've been using it for so long now that I'll never go back to the GUI version. Not sure how to resolve this though.

ghost commented 4 years ago

Not working for TA11 in its current state.