patchGNU Octave - Patches: patch #10170, Improve file rename ergonomy

 
 

patch #10170: Improve file rename ergonomy

Submitter:  Remi Thebault <rtbo>
Submitted:  Wed 19 Jan 2022 10:30:58 PM UTC
   
 
Category:  Core : other Priority:  5 - Normal
Status:  Done Privacy:  Public
Assigned to:  None Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Fri 18 Feb 2022 08:02:15 PM UTC, comment #25: 

@Remi, I have commented your final patch, pushed it with cset http://hg.savannah.gnu.org/hgweb/octave/rev/00ff0dfb4d27 and added you to the list of contributors.

Thanks again for this patch. Closing this patch report.

Torsten Lilge <ttl>
Group Member
Fri 18 Feb 2022 07:19:27 PM UTC, comment #24: 

OK, the "unmodified" bug I saw in comment #21 works fine now. If I change the file name of any file in the editor the editor tab is also renamed.
Thank you Torsten.

I only tested in Linux but I'll believe blindly it'll work on Windows as well :-)

Philip Nienhuis <philipnienhuis>
Group Member
Tue 15 Feb 2022 08:18:22 PM UTC, comment #23: 

@Torsten:
OK, thx, I'll try to make a new build soon.

Philip Nienhuis <philipnienhuis>
Group Member
Tue 15 Feb 2022 07:37:26 PM UTC, comment #22: 

@Philipp, I have changed the way how renamed/removed files are handled by the editor with cset http://hg.savannah.gnu.org/hgweb/octave/rev/2f6904439d3c which should fix the issue you have found with modified files.

Now I will take care of the latest version of Remi's patch :-)

Torsten Lilge <ttl>
Group Member
Tue 08 Feb 2022 09:02:12 PM UTC, comment #21: 

Unmodified. Works flawlessly.

With a modified file there's a surprise:

'edit tryfile.m'  ## (new file)
==> opens function tryfile.m in editor.

>> edit some stuff, don't save
>> in File Browser, rename 'tryfile.m' to 'tryfile2.m'

==> opens tryfile2.m in a new tab !?  and the popup shows.
Clicking "Save" seems to preserves the original non-renamed file.

... so there's a little bug there with modified files ...

BTW closing Octave in Linux makes Octave crash (grey window) & Plasma popup "Terminate application?

(Windows 11 & Mageia 8, Octave-8.0.0)

Philip Nienhuis <philipnienhuis>
Group Member
Mon 07 Feb 2022 09:11:56 PM UTC, comment #20: 

We were anyhow drifting away from the patch :-)
Was your test in comment #15 with a modified or non-modified file?

Torsten Lilge <ttl>
Group Member
Mon 07 Feb 2022 08:20:30 PM UTC, comment #19: 

My point is that apart from the file name nothing has changed. The Save dialog warning can wait until the editor tab is closed, just like if the file hadn't been renamed.
There IS a heads up for the user: there's a modified file icon (blue rather than grey) to the left of the file name in the editor tab, before and (if not saved) after renaming.

It's obviously safer to save the file tab contents to disk, sure. But why should that happen after a file rename?

Anyway, I've made my point, I'll shut up now and I'll happily accept the outcome :-)

Philip Nienhuis <philipnienhuis>
Group Member
Mon 07 Feb 2022 06:03:07 PM UTC, comment #18: 

When renaming a file that is open in the editor, but not modified, there isn't a save file dialog when the file is renamed (which is broken by the patch). This is only the case if the file is currently modified. Is renaming a file that has the modified state in the editor without any "heads up" for the user a good idea?

Torsten Lilge <ttl>
Group Member
Mon 07 Feb 2022 12:45:27 PM UTC, comment #17: 

Right, but still adapt the text on the File Save popup? or why have that popup at all?
I'd think that if the file is just renamed and nothing else, there shouldn't be any reason to save the editor tab contents. Those are still in the same state as before the renaming (up-to-date on disk or not), all that is changed is just a property of the file handle (name on disk). So IMO all that is really needed is to just update the file name in the editor tab.
Or ... ?

(I'm sorry for the nitpicking :-) but I try to look at these things from a users and ergonomics POV.)

Philip Nienhuis <philipnienhuis>
Group Member
Sun 06 Feb 2022 08:01:11 PM UTC, comment #16: 

The intended (and current) way is that the editor silently closes the old file before renaming and loads the renamed file at the same tab location after the file has been renamed. The user only sees that the filename in the editor's tab is updated.

I think, for this we need to handle the renaming by ourselves.

Torsten Lilge <ttl>
Group Member
Sun 06 Feb 2022 06:58:04 PM UTC, comment #15: 

Tried patch #4 (in Mageia 8) with Octave-8.0.0

I see the file editor popup, it offers to save or close the file. When clicking "Close" the file is gone in the editor, when clicking "Save" the editor file tab neatly shows the new name.

Is that what was intended? I can also imagine users wanting that Octave would rather retain the old file name and just offers to save it again with the old name. Admittedly could be far-fetched - it's just up to you, I have no opinion about desired behavior.
But I suppose it should be documented somewhere, probably in that file save popup dialog, s/th along the lines of '...save with the new file name'.

Philip Nienhuis <philipnienhuis>
Group Member
Sat 05 Feb 2022 11:34:00 PM UTC, comment #14: 

commentaire #13 :

> The issue with renaming a file using the context menu entry is related to the "focus follows mouse" preferences.

I've tested with Sway with and without the focus follows mouse option, but I can still rename with the context menu. What system/desktop are you on?


> However, there is another issue with the patch: When renaming a file that is currently open in the editor, the editor tab is not updated but the dialog that the file was externally removes appears.

The patch #4 fixes this. I send a signal before and after renaming as done by the current implementation. I have to do this in a QFileSystemModel subclass however.



(file #52809)

Remi Thebault <rtbo>
Sat 05 Feb 2022 03:06:03 PM UTC, comment #13: 

The issue with renaming a file using the context menu entry is related to the "focus follows mouse" preferences.

However, there is another issue with the patch: When renaming a file that is currently open in the editor, the editor tab is not updated but the dialog that the file was externally removes appears.

This might be fixed (I only had a brief look into QItemdelegate)  by manually performing more actions of the QItemDelegate object: possibly by using closeEditor and/or re-implementing setModelData for informing the editor (as is now done in contextmenu_rename) before and after the file is renamed.

Torsten Lilge <ttl>
Group Member
Fri 04 Feb 2022 04:55:40 PM UTC, comment #12: 

No problem, I can debug the right menu click behavior on my system.

Personally, I would prefer having the same behavior for F2 and the related menu entry.

Torsten Lilge <ttl>
Group Member
Fri 04 Feb 2022 01:00:48 PM UTC, comment #11: 

Thanks for the comments!

In the current state of the patch, the right-click menu entry should normally trigger the selected file to go in edit mode in the file tree (exactly as does the F2 key).
If it doesn't it will be difficult to debug because it does on my system.

Regarding showing to user that F2 can be used, I can simply update the tooltip.

I've figured out the issue with sorting after rename. Before I post the update can you clarify which behavior you prefer on the right click menu? (dialog with or without extension selected? or in-tree edition?)
I personally doesn't have strong opinion on this matter. I will only use the F2 key once I know it exists.

Remi Thebault <rtbo>
Fri 04 Feb 2022 12:05:04 PM UTC, comment #10: 


> Still, for me the menu entry does nothing. Only F2 is working.

That is by the OP's design - see comment #5 answer to 2nd question.

Philip Nienhuis <philipnienhuis>
Group Member
Thu 03 Feb 2022 09:04:59 PM UTC, comment #9: 

I like the patch, too.

Still, for me the menu entry does nothing. Only F2 is working.

Torsten Lilge <ttl>
Group Member
Thu 03 Feb 2022 08:28:32 PM UTC, comment #8: 

@Torsten:
Actually my habits are a non-issue :-)
I use several methods for getting a full filename, what I described in comment #6 is AFAIK the only one available in current Octave. Copying it from outside (File Explorer or Konqueror) also works well and with the patch, F2 / Shift-End / Ctrl-C is another way inside Octave.
Essentially it's all a mere matter of getting used to.

IMO we wouldn't even have to specify F2 explicitly as AFAICT it's used in about all file explorers and file browsing dialogs on Linux and Windows (maybe not on OSX, dunno). I'd think it's just nice for users to discover that it works just as everywhere else.

I like the patch.

Philip Nienhuis <philipnienhuis>
Group Member
Thu 03 Feb 2022 06:49:38 PM UTC, comment #7: 

First of all, thanks for the patch.

@Philip: In general, I would prefer an action behaving in the same way, whether activated by shortcut or by the menu entry. Otherwise this might be confusing, especially as the shortcut F2 is shown in the "Rename ..." menu, which suggests that both ways are equivalent.

But I see your point, Philip. Would it be a solution for you to get used to the sequence F2 - Ctrl-A - Ctrl-C in order to copy the full filename? That's what I am using when copying a full filename in the Gnome file epxlorer.

However, on my system, the menu entry does not trigger the action.

Torsten Lilge <ttl>
Group Member
Thu 03 Feb 2022 10:06:57 AM UTC, comment #6: 

I was unclear, sorry.
The rename option in the RMB menu is still there, obviously, but there's no more popup rename dialog when clicking it. As you outline below, correct.

I'd say <F2> should work more or less silently in tree view and RMB + clicking "rename" should pop up the dialog. IOW, I see <F2> as additional rather than as replacement.
But who am I ...

One of my motives is that I often let the dialog popup and then do Ctrl-C to copy the entire file name for subsequent use in some script of function argument. So in the rename dialog a fully preselected file name incl. extension would be bandy, and with F2 in the file browser tree view just the file name. But of course we can expect different opinions here :-)

Philip Nienhuis <philipnienhuis>
Group Member
Thu 03 Feb 2022 04:53:17 AM UTC, comment #5: 

commentaire #4 :

> Did you completely remove the "Rename" menu when RMB-ing on a file name in the File Browser pane? because the option is still there but does nothing.

This is weird, the same QAction is used for the <F2> key and the context menu. Do you not see "F2" on the menu next to "Rename" (see my screenshot).
Is it possible that you didn't notice that the file name was in edit mode in the tree view after right click?

> For the time being I think it may be handy to keep that popup window around.

The rename dialog is gone. Instead I trigger the same action as the <F2> key.
Would you prefer to have a different action for right click and <F2>? This is generally not a recommended practice, but if the user do not notice what happens after right click, it may help.

I have noticed that the sort by name do not change order after a file is renamed. This possibly comes from my patch because I have removed some logic in the rename handler (which should be done by QFileSystemModel)


Remi Thebault <rtbo>
Wed 02 Feb 2022 10:43:27 PM UTC, comment #4: 

I tried your patch with Octave-8.0.0 (dev) on Linux and Windows 11, and it works perfectly.

Did you completely remove the "Rename" menu when RMB-ing on a file name in the File Browser pane? because the option is still there but does nothing.
For the time being I think it may be handy to keep that popup window around.

cc-ing the Qt specialist.

Philip Nienhuis <philipnienhuis>
Group Member
Wed 02 Feb 2022 11:22:11 AM UTC, comment #3: 

Hi, here is the patch with F2 key. I took care that the F2 shortcut is only active when the file tree has focus. Otherwise you can rename files when the file tree is not even on screen!

I think it is complete for me. Can you please test on your side?

(file #52792)

Remi Thebault <rtbo>
Mon 31 Jan 2022 11:01:14 PM UTC, comment #2: 

Yes I agree it's better.
Here is a patch for editing the name in the tree view (still with pre-selection up to the extension).
Still have to figure out for the F2 shortcut.

(file #52784)

Remi Thebault <rtbo>
Sat 22 Jan 2022 09:06:26 PM UTC, comment #1: 

One can ask why a separate file rename dialog is needed in the first place.
E.g., in Dolphin (KDE/Plasma) and Windows Explorer, just clicking a file name and hitting the <F2>-key allows one to change the file name (excl. extension).
Could the file browser be fitted with the same functionality?

Philip Nienhuis <philipnienhuis>
Group Member
Wed 19 Jan 2022 10:30:58 PM UTC, original submission:  

This is a patch that improves the ergonomy of the file rename dialog by pre-selecting the text of the filename up to the extension.

That way, the user can directly type the filename without having to either deselect or retype the extension.

Remi Thebault <rtbo>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #52809:  patch_10170_4.patch added by rtbo (8KiB - text/x-patch)
file #52792:  patch_10170_3.patch added by rtbo (6KiB - text/x-patch)
file #52784:  patch_10170_2.patch added by rtbo (4KiB - text/x-patch)
file #52687:  improve-rename.patch added by rtbo (4KiB - text/x-patch)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by ttl (Posted a comment)
  • -email is unavailable- added by philipnienhuis
  • -email is unavailable- added by rtbo (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 10 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-02-18 ttl StatusIn Progress Done
        Open/ClosedOpen Closed
    2022-02-15 ttl StatusReady For Test In Progress
    2022-02-05 rtbo Attached File- Added patch_10170_4.patch, #52809
    2022-02-03 rtbo Attached File- Added patch_10170_right@click.png, #52796
    2022-02-02 philipnienhuis StatusNone Ready For Test
        Carbon-Copy- Added ttl
    2022-02-02 rtbo Attached File- Added patch_10170_3.patch, #52792
    2022-01-31 rtbo Attached File- Added patch_10170_2.patch, #52784
    2022-01-19 rtbo Attached File- Added improve-rename.patch, #52687

    Back to the top

    Powered by Savane 3.13-4b48.
    Corresponding source code