rgieseke / textredux

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

Fix save_buffer_as #43

Closed ghost closed 5 years ago

ghost commented 5 years ago

The old function would save an arbitrary buffer instead of the current one. Also changed the overwrite confirmation to be more apparent.

Could you have a look and let me know if you find any errors?

ghost commented 5 years ago

This will now always pop up a window asking the user for a filename. A filename will always be preselected. Consider the case where the user wants to save a file as "foo" but a file named "foobar" already exists. In this case the input box will have "foobar" preselected but the user can change it to "foo" or simply press OK to overwrite the existing file.

rgieseke commented 5 years ago

Nice, thanks! I will need to try this out a bit more ...

rgieseke commented 5 years ago

Using this more ... what do you think, should it maybe display the full path in the final conformation box?

ghost commented 5 years ago

Do you mean just display or actually let the user edit the full path? The first certainly seems like a good idea, second not so much. I'm thinking display the entire path but only let the user edit the filename.

Another thing that came to mind is that you can't save something if it matches a directory. This is because it will enter that directory instead of calling the dialog function. I haven't really thought about it much but it would probably need changes to the select_file function. A bit like the select_directory function where the select part is assigned a different hotkey.

rgieseke commented 5 years ago

Good points, display only would certainly be the right thing to do ... On the other issue, this is probably why i ended up removing the save as functionality and just using the built-in dialogue. Not sure what to do ...If there is a "native" dialogue popping up anyway, one could as well use the native one ...

ghost commented 5 years ago

I prefer having a TR dialog over the native one mainly for the snappy navigation it offers (it also looks/feels much nicer than the native one). The other consideration for writing a new function for this was that the current save_buffer_as is very broken. I'll look into mitigating the directory issue. It doesn't happen that often, at least in my experience.

rgieseke commented 5 years ago

I'll look into mitigating the directory issue. It doesn't happen that often, at least in my experience.

Awesome!

ghost commented 5 years ago

I've added a hotkey to "forcesave". Basically this lets the user forcibly call the save_as function even when fuzzy search would prevent the function being called normally. E.g.: Consider a folder named "foobar" existing. The user now wants to save a file in the same directory called "foo". Using the normal method he would just enter the "foobar" directory instead of saving. Using "ctrl+f" he can now forcesave and save the file as "foo".

Would appreciate feedback.

rgieseke commented 5 years ago

Since it's possible to overwrite files inadvertently with the save as dialogue i'm quite reluctant to include something that differs from the "default" system dialogue as it might confuse users. Maybe it's something for a separate plug-in? I'd likely use it myself.

ghost commented 5 years ago

Good point. I changed things around to make this (hopefully) impossible to happen. Now the overwrite check is a simple messagebox to be more in line with other TA dialogs. The check also gets invoked when forcing the save.

ghost commented 5 years ago

Have you had a chance to review the changed version yet?

rgieseke commented 5 years ago

Not really - i'm leaning on having this as an external plugin. I think it's better to keep Textredux core to text-only interfaces. For a 'save as' dialogue it should work as the system dialogue.

We should have a section in the Readme with links to plugins - you have quite a few ...

ghost commented 5 years ago

Not sure I follow the reasoning but I don't mind. As you aptly observed I have too many modules already so I won't make this into another one but rather keep it as a patch.

Regarding a plugin/module section I don't think it makes sense as this doesn't really have enough reach. If anyone wants more exposure for their module(s) they could always ask Mitchell to put it on the wiki. If however you do decide to make a section anways I'd kindly ask not to be included as I don't think my modules are production-ready. I only keep them on GH to have an easy way to deploy them when I set up TA on a new machine.

Cheers.

ghost commented 5 years ago

Didn't see you already included the list, sorry about that. As I explained above I'd rather not be part of it. I'm sure there are other modules you can mention however.

rgieseke commented 5 years ago

Reverted, sorry for the premature inclusion. At the moment i don't feel comfortable including and maintaining this, as it breaks the text-only interface Textredux provides and i personally probably won't use it (if i have to pop up a GUI dialogue i can use the default GUI dialogue)

Thanks again for your contribution(s)!

ghost commented 5 years ago

(if i have to pop up a GUI dialogue i can use the default GUI dialogue)

I still don't follow. Maybe I just explained it poorly but there is no GUI popping out anywhere. The selection is done entirely within the TR interface. Only the confirmation to overwrite a file (which tries to be close to the normal TA confirmation dialogs with the "safe" option preselected) is a GUI element.
If the user wants to save a file but the fuzzy search gets in the way the save can be forced (currently via Right). Inadvertently overwriting a file should not be possible anymore either.

Admittedly I did not test this under MacOS so it's possible that the behavior differs there.