Inconvenience with cm_CompareFilesByContent

Here you can propose new features, make suggestions etc.

Moderators: white, Hacker, petermad, Stefan2

Post Reply
jb
Senior Member
Senior Member
Posts: 412
Joined: 2003-02-09, 22:56 UTC
Location: Switzerland

Inconvenience with cm_CompareFilesByContent

Post by *jb »

The command cm_CompareFilesByContent basically still works as follows with tcmd75b3:
1. Concatenate the selection of the left and right pane according to the sort order of each pane (S = SL + SR).
2. Remove last element of S while S.Count > 2.
3. Pass all elements of S to the executable specified by [Configuration]Comparetool. Note that now S may contain 0, 1 or 2 elements.

The main problem is that the order of the passed arguments depends on the sort order instead of the selection order.
The order is especially important for compare tools that do not show the two files side by side but MERGE one file into the other one and mark the changes as deletions or insertions. For example the compare functions of Microsoft Word and OpenOffice Writer work this way.
To make the picture complete I would like to mention that my compare tool is a script that acts just as a "compare tool switch", that is, the script calls one of various compare tools depending on the extension of the first file name. (This approach can also be applied to [Configuration]Editor by the way.)

I suggest that cm_CompareFilesByContent works as follows:
If the total number of selected items in the left and right pane is not equal to 2 then TC issues an error message saying that cm_CompareFilesByContent requires exactly 2 parameters.
Otherwise TC passes the selected item with the focus as 2nd parameter and the other selected item as 1st parameter to the compare tool.

Minor benefits:
- Prevent useless calls of the compare tool with 0 and 1 arguments.
- Prevent calls of the compare tool with 2 arguments if more than 2 items are selected. The passed arguments may not be the intended ones.
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

I think it will be more convenient if TC will compare _focused_ files when miltiple selection exists.
jb
Senior Member
Senior Member
Posts: 412
Joined: 2003-02-09, 22:56 UTC
Location: Switzerland

Post by *jb »

Your suggestion does NOT solve the problem when 2 files are selected in one pane and 0 files are selected in the other one. Currently the upper file is passed as 1st argument and the lower file is passed as 2nd argument regardless of the select order. So if I want to swap the arguments I have to reverse the sort order and this additional step is annoying for me.

While I was writing this response I realized that my suggestion above is undefined in the case when the focused file is not selected. This is possible at least in the following ways:
1. Select 2 files and move the focus away with the UP or DOWN key.
2. Select 3 files and then de-select 1 of them.

Now it seems to me that only keeping track of the select order could really solve the problem but this may be too expensive.
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

About 2:0 selection: just make active panel w/o selected files and put focus onto file that you want to compare with selected file from other panel - it is logical (and I offen use such action to compare files with different names - I select a file in one panel and focus a file in other).

But I agreed that it is a BUG (old bug) - when we have on both panels more than 2 files selected, comparer opens two first selected files FROM ACTIVE PANEL instead of comparing some file from left with some file from right (your version in 1st post was a bit inaccurate).

I think easier way to make clear situations with selections - to ignore selections at all (pass focused files always) or to pass selected_and_focused file as parameter if one of selected files has focus (on each panel of course). I think this won't confuse old TC users.

Or maybe add some option to choose behaviour in such cases (ignore selection, first selected on each panel, selected_and_focused, error message and so on).
jb
Senior Member
Senior Member
Posts: 412
Joined: 2003-02-09, 22:56 UTC
Location: Switzerland

Post by *jb »

MVV wrote:But I agreed that it is a BUG (old bug) - when we have on both panels more than 2 files selected, comparer opens two first selected files FROM ACTIVE PANEL instead of comparing some file from left with some file from right (your version in 1st post was a bit inaccurate).
I do NOT agree because:
  1. There is no bug in the case with 2 or more selected files. I just criticized that the behavior in this case is inconvenient because the order of the passed arguments depends on the sort order instead of the select order.
    (In my second post I recognized that unfortunately there is no cheap solution for the order problem.)
  2. I think the first four lines of my initial post describe the current behavior in this case quite concisely and accurately.
MVV wrote:I think easier way to make clear situations with selections - to ignore selections at all (pass focused files always) ....
You ignore that fact that the focus in the inactive panel is not visible. This makes your suggestion useless in my opinion.
Furthermore I think that the selection should be the primary criterion and the focus of the active panel can be a secondary criterion only if less than 2 files are selected (as it is now).
Actually I find the current behavior of Total Commander quite clever, especially in the cases where 0 or 1 file is selected (try it out with two similar directories in the left and the right panel!). Apart from the order problem I also appreciate the behavior in the case of "2:0 selection" (as you call it) because it allows you to compare two files listed in the same panel with minimal effort.
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

I already showed to you inaccuracy of your first 4 lines of initial post. To check it select files 1.txt and 2.txt on the left panel, 3.txt and 4.txt on the right and call compare having RIGHT panel active. Your initial post says that 1.txt and 2.txt should be compared - but TC will compare 3.txt and 4.txt - as I said, 'comparer opens two first selected files FROM ACTIVE PANEL'.

I agreed that 0 and 1 total file selected cases TC process correctly. But I disagree that if both panels have selection, TC should use two files from the same panel instead of trying to compare files from both panels. It is logically that comparer compares 'left file' and 'right file'. Why both files should be taken from same panel??
jb
Senior Member
Senior Member
Posts: 412
Joined: 2003-02-09, 22:56 UTC
Location: Switzerland

Post by *jb »

MVV wrote:I already showed to you inaccuracy of your first 4 lines of initial post. To check it select files 1.txt and 2.txt on the left panel, 3.txt and 4.txt on the right and call compare having RIGHT panel active. Your initial post says that 1.txt and 2.txt should be compared - but TC will compare 3.txt and 4.txt - as I said, 'comparer opens two first selected files FROM ACTIVE PANEL'.
OK, there is a slight inaccuracy.
"1. Concatenate the selection of the left and right pane according to the sort order of each pane (S = SL + SR)."
should be replaced by
"1. Concatenate the selection of the active and inactive pane according to the sort order of each pane (S = SA + SI)."
MVV wrote:I agreed that 0 and 1 total file selected cases TC process correctly. But I disagree that if both panels have selection, TC should use two files from the same panel instead of trying to compare files from both panels. It is logically that comparer compares 'left file' and 'right file'. Why both files should be taken from same panel??
Because the selection in the inactive panel may be from a previous operation and it is not necessary to change it. If you really intend to compare two file from different panels then just select one in each panel.
Post Reply