Solved [TC 10.50b1] new /P parameter does not work if parent dir is the root

Bug reports will be moved here when the described bug has been fixed

Moderators: Hacker, petermad, Stefan2, white

Post Reply
User avatar
petermad
Power Member
Power Member
Posts: 16030
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Solved [TC 10.50b1] new /P parameter does not work if parent dir is the root

Post by *petermad »

if I use this command:

Code: Select all

%COMMANDER_EXE% /N /P /A "C:\totalcmd\Plugins" "C:\totalcmd\Language"
it works as expected and opens the left panel in C:\totalcmd with the cursor on the Plugins directory, and opens the right panel in C:\totalcmd with the cursor on the Language directory.

But if I use this command:

Code: Select all

%COMMANDER_EXE% /N /P /A "C:\totalcmd" "C:\totalcmd\Language"
then the left panel is unexpectedly opened in C:\totalcmd\Language with the cursor on [..] in the top of the file panel. The right panel correctly opens in C:\totalcmd with the cursor on the Language directory..

Expected behavior would be to open the left panel in C:\ with the cursor on the totalcmd dir.

But if I use this command:

Code: Select all

%COMMANDER_EXE% /N /P /A "C:\totalcmdPlugins" "C:\totalcmd"
then the left panel opens in C:\totalcmd with the cursor on the Plugins directory as expected, but unexpectedly opens the right panel in C:\totalcmd with the cursor on [..]


A suggestion for improvement for the /P parameter for use from inside TC in buttons etc., would be to distinguish between for example C:\totalcmd and C:\totalcmd\ so that the first would open in C:\ with the cursor on totalcmd and the latter would open in C:\totalcmd with the cursor on [..]

This way a command like:

Code: Select all

[em_newcommander]
cmd=%COMMANDER_EXE% /N /P /A
param=%X %P%N %T%M
will also work correctly if the cursor is placed on [..] in the left panel - it already works OK with the cursor on [..] in the right panel.
Last edited by petermad on 2022-04-28, 02:42 UTC, edited 1 time in total.
License #524 (1994)
Danish Total Commander Translator
TC 11.51 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1391a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50479
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: [TC 10.50b1] new /P parameter does not work if parent dir is the root

Post by *ghisler(Author) »

Unfortunately I cannot reproduce it, neither with TC 32-bit nor 64-bit.
This command:
%COMMANDER_EXE% /N /P /A "C:\totalcmd" "C:\totalcmd\Language"
opens C:\ on the left with the cursor on totalcmd, and C:\totalcmd on the right with the cursor on Language.

Maybe it depends on your settings? Could you send me your wincmd.ini, please?
Author of Total Commander
https://www.ghisler.com
User avatar
petermad
Power Member
Power Member
Posts: 16030
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: [TC 10.50b1] new /P parameter does not work if parent dir is the root

Post by *petermad »

I can reproduce it with a fresh ini file.

Make this button in your usual TC:

Code: Select all

TOTALCMD#BAR#DATA
"%COMMANDER_EXE%" /N /P /i="%COMMANDER_INI%" "C:\totalcmd" "C:\totalcmd\Language"

%COMMANDER_EXE%,6
Test of /P parameter


-1
Or this button:

Code: Select all

TOTALCMD#BAR#DATA
"%COMMANDER_EXE%" /N /P /i="%COMMANDER_INI%" /L="C:\totalcmd" /R="C:\totalcmd\Language"

%COMMANDER_EXE%,6
Test of /P parameter with /L and /R


-1
Copy one of the butttons by right-clicking it in the buttonbar - or copy it here from the webpage.

Start a new instance of TC with the parameter /i=%COMMANDER_PATH%/test.ini
Paste the copied button to the buttonbar in the new instance of TC.
Click the button.
It takes you to c:\totalcmd\Language in the left side with the cursor on [..] and to c:\totalcmd in the right side with the cursor on Language.

Another test - an what I actually want to accomplish is that this button will alwyas open a new instance of TC in the same dirs and with the cursor on the same dirs/files as in the original TC instance:

Code: Select all

TOTALCMD#BAR#DATA
%COMMANDER_EXE% /N /P /A /i=%COMMANDER_INI%
%X %P%N %T%M
%COMMANDER_EXE%
Open new instance of TC in the same dirs with cursor on the same elements


-1
An it works perfectly - except when the cursor is on [..] on the left side. It works fine with the cursor on [..] in the right side or with the cursor on [..] in both sides. EDIT - it also does not work if I am in the root in one or both panels, then it goes into the directories the cursor is on.
License #524 (1994)
Danish Total Commander Translator
TC 11.51 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1391a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
User avatar
petermad
Power Member
Power Member
Posts: 16030
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: [TC 10.50b1] new /P parameter does not work if parent dir is the root

Post by *petermad »

history.txt wrote:19.04.22 Fixed: The new parameter /P to go to the parent of the path parameter(s) and focus the last folder part didn't always work for folders in the root of a drive (32/64)
I can confirm the fix in TC 10.50b2.

But I would still like it to work in a way so this button:

Code: Select all

TOTALCMD#BAR#DATA
%COMMANDER_EXE% /N /P /A /i=%COMMANDER_INI%
%X %P%N %T%M
%COMMANDER_EXE%
Open new instance of TC in the same dirs with cursor on the same elements


-1
Would alway start a new TC with the came folders open and the cursor placed on the same folder/file as the originating TC.

Now it works when the cursor is NOT on [..].
When the fursor is on [..] %P%N and %T%M returns the current dir with a backslash - so if the rule for using /P was that folders entered with a backslash is not opened in parent dir but in passed dir with the cursor on [..] then it could also work for this button.
License #524 (1994)
Danish Total Commander Translator
TC 11.51 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1391a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50479
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: [TC 10.50b1] new /P parameter does not work if parent dir is the root

Post by *ghisler(Author) »

Thanks for confirming the fix!

Passing ".." for %N sounds like a bad idea, it would probably break other programs expecting just the folder when nothing is selected. :(
Author of Total Commander
https://www.ghisler.com
User avatar
petermad
Power Member
Power Member
Posts: 16030
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: [TC 10.50b1] new /P parameter does not work if parent dir is the root

Post by *petermad »

2ghisler(Author)
It is not the handeling of the %N or the %M parameter I would like to change. It is the rule the /P start parameter uses - simply if the path ends with a backslash, go into the dir, and if it does not end with a backslash go into the parent dir and place the cursor on the last dir name.

Since /P is a new parameter, it cannot break any backwards compatability - it only requires that the difference between past with or without trailing backslash is documented in the Help.
License #524 (1994)
Danish Total Commander Translator
TC 11.51 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1391a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50479
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: [TC 10.50b1] new /P parameter does not work if parent dir is the root

Post by *ghisler(Author) »

simply if the path ends with a backslash, go into the dir, and if it does not end with a backslash go into the parent dir and place the cursor on the last dir name.
That would indeed solve your specific problem, but would cause other problems. For example:
/P %P %T
would not work because %P and %T always end with a backslash, otherwise they couldn't be combined with other parameters...
Author of Total Commander
https://www.ghisler.com
User avatar
petermad
Power Member
Power Member
Posts: 16030
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: [TC 10.50b1] new /P parameter does not work if parent dir is the root

Post by *petermad »

/P %P %T
Well there is a solution for that - just use:
/P %P:~0,-1 %T:~0,-1

Which is already what users have to do if they want the path without backslash for programs that does not support backslashes in the command line.
License #524 (1994)
Danish Total Commander Translator
TC 11.51 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1391a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50479
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: [TC 10.50b1] new /P parameter does not work if parent dir is the root

Post by *ghisler(Author) »

That doesn't work in the root because it would just pass c: to the called app.
Author of Total Commander
https://www.ghisler.com
User avatar
petermad
Power Member
Power Member
Posts: 16030
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: [TC 10.50b1] new /P parameter does not work if parent dir is the root

Post by *petermad »

ghisler(Author) wrote: 2022-04-24, 08:06 UTC That doesn't work in the root because it would just pass c: to the called app.
Hmm, it turns out that both:
%COMMANDER_EXE% /N /P "C:\" "C:\Totalcmd\Language"
and
%COMMANDER_EXE% /N /P "C:" "C:\Totalcmd\Language"

does NOT work as expected - they open "C:\Totalcmd\Language" in the left file panel - expected would be to open C:\ in the left panel.

So you have to handle the root specifically anyway.
License #524 (1994)
Danish Total Commander Translator
TC 11.51 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1391a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50479
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: [TC 10.50b1] new /P parameter does not work if parent dir is the root

Post by *ghisler(Author) »

There is no parent of c:\ so you can't expect a reasonable result here when using parameter /P.
Author of Total Commander
https://www.ghisler.com
User avatar
white
Power Member
Power Member
Posts: 5789
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Re: [TC 10.50b1] new /P parameter does not work if parent dir is the root

Post by *white »

ghisler(Author) wrote: 2022-04-25, 11:27 UTC There is no parent of c:\ so you can't expect a reasonable result here when using parameter /P.
Following your reasoning, when we click on the ".." button in Total Commander while c:\ is shown, we should expect an unreasonable result.
User avatar
petermad
Power Member
Power Member
Posts: 16030
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: [TC 10.50b1] new /P parameter does not work if parent dir is the root

Post by *petermad »

The problem is that with the current implementation
neither: /P %P %T
nor: /P %P:~0,-1 %T:~0,-1
works when in the root
License #524 (1994)
Danish Total Commander Translator
TC 11.51 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1391a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
User avatar
petermad
Power Member
Power Member
Posts: 16030
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: [TC 10.50b1] new /P parameter does not work if parent dir is the root

Post by *petermad »

I found a workaround:

Code: Select all

TOTALCMD#BAR#DATA
%COMMANDER_EXE% /N /P /i=%COMMANDER_INI%
%X %P%N* %T%M*
%COMMANDER_EXE%
Open new instance of TC in the same dirs with cursor on the same elements


-1
Putting * at the end of %P%N and %T%M seems to do it - it even works in the root.

Teh behaviour when the cursor is on [..] can even be restricted to one file panel or the other like this:
/P %P%N %T%M*
or
/P %P%N* %T%M

If works partially for network shares - here the cursor is always placed on [..] but the wanted dirs are opened

It does not work in Network Neighborhood - but neither did my old solution prior to the /P parameter:

Code: Select all

TOTALCMD#BAR#DATA
%COMSPEC% /C
%X if exist %P%N\* (if exist %T%M\* (start "" "%%COMMANDER_EXE%%" /N /A /i="%%COMMANDER_INI%%" "%P" "%T") else start "" "%%COMMANDER_EXE%%" /N /A /i="%%COMMANDER_INI%%" "%P" %T%M) else if exist %T%M\* (if exist %P%N\* (start "" "%%COMMANDER_EXE%%" /N /A /i="%%COMMANDER_INI%%" "%P" "%T") else start "" "%%COMMANDER_EXE%%" /N /A /i="%%COMMANDER_INI%%" %P%N "%T") else start "" "%%COMMANDER_EXE%%" /N /A /i="%%COMMANDER_INI%%" %P%N %T%M
%COMMANDER_EXE%
Open new instance of TC in the same dirs with cursor on the same file names (not folder names)


-1
License #524 (1994)
Danish Total Commander Translator
TC 11.51 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1391a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
Post Reply