Ctrl+D Directory hotlist: adding/deleting submenu items mixes up [DirMenu] order in INI

The behaviour described in the bug report is either by design, or would be far too complex/time-consuming to be changed

Moderators: white, Hacker, petermad, Stefan2

Post Reply
StatusQuo
Power Member
Power Member
Posts: 1524
Joined: 2007-01-17, 21:36 UTC
Location: Germany

Ctrl+D Directory hotlist: adding/deleting submenu items mixes up [DirMenu] order in INI

Post by *StatusQuo »

(Minor, because I found a workaround):
Directory hotlist (Ctrl+D) and [DirMenu] section in WINCMD.INI:
  • When using "Ctrl+D > Add current dir" to add a dir to an existing submenu in directory hotlist, the lines in WINCMD.INI get mixed up:
    "menu" line gets correctly added in the selected submenu,
    but "cmd" and "path" lines get appended at the end of [DirMenu] section.
  • When deleting the last/bottom item inside a submenu, the next entry after the submenu is messed up in the same way
  • Additionally a bunch of other existing lines get mixed up like this by a single add/delete command
    (currently 27 out of 229 items in my list).
Reproducible in TC up to 9.50b13 32+64bit (Win7 x64).
Seems to exist since TC 8.0, when "[X] Add to submenu" was introduced.
TC 7.57a was OK.

Suggestion:
It seems that all above already get auto-corrected in WINCMD.INI after opening Directory hotlist: Ctrl+D > configure > OK (even without changes),
so obviously there already is a repair function, that's called after using Ctrl+D and leaving with OK.
=> Maybe this function can simply be called after adding/deleting items from the hotlist menu itself?

To reproduce:
([DirMenu] should contain submenus, like in the test data attached here)
- before testing: for later comparison create a backup copy of your INI containing the [DirMenu] section
- navigate to a directory that's not yet in the list
- press Ctrl+D > Add current dir > [X] Add to submenu > (select the first submenu from the list) > press Enter (OK)
(=> now INI is already mixed up, but will be better comparable after deleting the new line again:)
- press Ctrl+D > Remove current dir
- use "File > Compare by content" to see the differences:

=> 27 items moved to the bottom of the section
(but only "cmd" and "path" parts, position of the "menu" part stays unchanged).
Test data (archive): [DirMenu] before and after the test

Code: Select all

begin 644 usermenu-dir_add-to-submenu.rar
M4F%R(1H'`)O7<T@`#0````````!^\W2`D#@`W0,``,4<```"SAF0!ABG.U`=
M,Q,`(````'5S97)M96YU+61I<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PH?*C^9)L%G
M5F`%AP878"_$;&F]!\!C6VSUEV$S;[R;4M(@G*DTL)V^D,?-+0U3H<H?$1YM
MU$HC4=%#<0V>S6O$#HL1Q<L<)=9WWN3#F??=Z`[6?-F^6J`H'1->\'TZ2V/W
M`;J\["9/N:$Z"WAVZ2FA*6LG$D")C:<*B!+")>)RK#Q1;GIHL7'>H[-]S$I_
MYH1.:IN'I<!`2&^<_!"M@4E+.:$L7"L!\T(&P4@G/A8TB>6ZBZ])&[360GPZ
M=A5*(2UH/;30<L-&:MT7.-0^7NK;@1WKV\MIR'Y"TA&P&HI/'KSITK34VM:[
MY$&(6-E*,GN'*[,1(&3LB_0R?JJ@_R"R!D%D#(+(&060,@L@9!9`R"J@?_"S
MJC@<@J3!F%F"84)F%F#,+,&868)A0DPH3,+0&@6@-`M`3"C-)%2*F3",([`D
MI-+%-,'+MZ%[>GD#_2O+V+I92_6%'#CC=]K-50=U"U!J%J#7)H]M9@QP!*UB
MI1$+(&068*+6B%%J#6N3MRHJP.0=K`V"V!L%L#9^JL>Q:*F3)KT[1R<H0V"V
MED9D.^R4F%5X2,*4"J\2V"Y(7\<+WO.R+AI;7Z7;X-HS?!U0LW"S@V:DS'I'
M8<5*(X\BD#+%-,&8J@-!50:BK`X@^42N\+.NK@7"G@Y"$#H*40QY%$'$/S@<
6D)$\%X5X/"SKK4&H6P.0Q#U[`$`'````
`
end
sum -r/size 48993/2857
Shorter test data (with less order corruption)

Code: Select all

[DirMenu]
menu1=title1
cmd1=cd C:\temp\1
path1=C:\temp\1
menu2=-submenu2
menu3=title3
cmd3=cd C:\temp\3
path3=C:\temp\3
menu4=NewDir
cmd4=cd d:\temp\NewDir
path4=d:\temp\TargetDir\
menu5=--
menu6=title5
cmd6=cd C:\temp\5
path6=C:\temp\5
menu7=title6
cmd7=cd C:\temp\6
path7=C:\temp\6
menu8=title7
cmd8=cd C:\temp\7
path8=C:\temp\7
gets changed to

Code: Select all

[DirMenu]
menu1=title1
cmd1=cd C:\temp\1
path1=C:\temp\1
menu2=-submenu2
menu3=title3
cmd3=cd C:\temp\3
path3=C:\temp\3
menu4=NewDir
cmd4=cd d:\temp\NewDir
path4=d:\temp\TargetDir\
menu5=--
menu6=title5
menu7=title6
cmd7=cd C:\temp\6
path7=C:\temp\6
menu8=title7
cmd8=cd C:\temp\7
path8=C:\temp\7
cmd6=cd C:\temp\5
path6=C:\temp\5
Who the hell is General Failure, and why is he reading my disk?
-- TC starter menu: Fast yet descriptive command access!
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48083
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: Ctrl+D Directory hotlist: adding/deleting submenu items mixes up [DirMenu] order in INI

Post by *ghisler(Author) »

This isn't a bug because the item order in the [DirMenu] section doesn't matter at all.

When you add an entry via Ctrl+D, TC only updates the changed lines via calls to the Windows INI file functions. These functions do not know about any item order, they just place new entries at the end of the section.

When you use the configuration dialog, the entire section is cleared and written again, so it will have the same order as the menu itself. But this isn't relevant for correctly displaying the menu.
Author of Total Commander
https://www.ghisler.com
StatusQuo
Power Member
Power Member
Posts: 1524
Joined: 2007-01-17, 21:36 UTC
Location: Germany

Re: Ctrl+D Directory hotlist: adding/deleting submenu items mixes up [DirMenu] order in INI

Post by *StatusQuo »

ghisler(Author) wrote: 2020-01-28, 10:10 UTC But this isn't relevant for correctly displaying the menu.
I agree, it's "only" useful for data comparing to a backup.
Which is not unimportant: This way I found missing/lost "cmd" and "path" lines for one item some days ago (only the title was left, no cause found yet).

Thanks for explaining (rewriting the whole INI section is a nice approach I didn't think about yet).
As TC seems to work as designed here, I'll check what I can do about it and meanwhile trust in the configuration dialog.
ghisler(Author) wrote: 2020-01-28, 10:10 UTC via Ctrl+D, TC only updates the changed lines via calls to the Windows INI file functions.
I have no doubt that those are not perfect and probably to blame. :)
Strange about that:
  • When inserting a menu item close to the top (as in my long example), all following get renumbered - but only 27 (randomly selected?) lines get moved down
  • TC manages to add the first line ("menu") at a sorted position
Who the hell is General Failure, and why is he reading my disk?
-- TC starter menu: Fast yet descriptive command access!
Post Reply