New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Panel.Select #691
Fix Panel.Select #691
Conversation
Looks good but you need to build Far and test. local a={}
for i=2,APanel.ItemCount do
a[#a+1] = Panel.Item(0, i)
end
for k=1,3 do
local m=k==1 and 1 or k==2 and 0 or 2 -- select, deselect, invert
Panel.Select(0, m, 2, table.concat(a,'\n'))
far.Text()
win.Sleep(2000)
end |
5422070
to
c58a086
Compare
This is a breaking change. We should fall back to the current logic if the item is not found, something like - const auto Pos = FindFile(PointToName(i), true);
+ auto Pos = FindFile(i, false);
if (Pos == -1)
- continue;
+ {
+ Pos = FindFile(PointToName(i), true);
+ if (Pos == -1)
+ continue;
+ } |
I wouldn't call that "works" as in case there are several "file.ext" on TmpPanel only 1 of them is processed. |
See my backward-compatibility fix: shmuz/far2m@4067c52 |
@johnd0e |
far/filelist.cpp
Outdated
@@ -982,7 +982,7 @@ long long FileList::VMProcess(int OpCode,void *vParam,long long iParam) | |||
if (i.empty()) | |||
continue; | |||
|
|||
const auto Pos = FindFile(PointToName(i), true); | |||
const auto Pos = FindFile(i, !wcschr(namePtr,LGOOD_SLASH)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It won't compile.
!wcschr(namePtr,LGOOD_SLASH)
-> !i.contains(path::separator)
.
This is still a bit incompatible: previously it was possible to select names like "q:\non_existing_or_completely_unrelated_path\file.ext"
, as long as there is file.ext
on the panel, but we can probably live with that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but we can probably live with that.
Hmm.. I rather see that as breaking change
far/filelist.cpp
Outdated
@@ -982,7 +982,7 @@ long long FileList::VMProcess(int OpCode,void *vParam,long long iParam) | |||
if (i.empty()) | |||
continue; | |||
|
|||
const auto Pos = FindFile(PointToName(i), true); | |||
const auto Pos = FindFile(i, !i.contains(path::separator)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, just realized this won't compile too (or at least not everywhere).
!i.contains(path::separator)
-> !contains(i, path::separator)
@alabuzhev lua:Panel.Select(0,1,2,"file.ext") |
I'm not saying it makes any sense though. |
Ah, I see now. @shmuz ? |
In my opinion the current solution is OK. BTW, when I and zg were changing the macrosystem to Lua, zg removed all macroapi functions (he thought they were unnecessary as we had LuaFAR API). Later I put them back. |
I made another change (not committed yet; as I'm writing the test for Panel.Select). auto SelectByList = [&] (ps_action act)
{
Result=0;
const wchar_t *name;
bool RegularPanel = !GetPluginHandle();
for(size_t I = 0; (name=itemsList.Get(I)) != nullptr; ++I)
{
int Pos;
auto arg1 = RegularPanel ? PointToName(name) : name;
auto arg2 = RegularPanel || !wcschr(name,LGOOD_SLASH);
if ((Pos=FindFile(arg1, arg2)) != -1)
{
Select(ListData[Pos], act==remove?FALSE : act==add?TRUE : !ListData[Pos]->Selected);
Result++;
}
}
}; |
The commit is here. Also, a 90-line test function was added. |
Thanks, synchronized. |
I'm a little confused. There are some API differences between Far3 and far2m and such a synchronization is a ... non-trivial task. |
I've picked what I could. |
I didn't (yet) look at your commit but for example in the test added today: ... But this may work for Far3 ... |
@alabuzhev |
Ref: https://forum.farmanager.com/viewtopic.php?p=174783#p174783