PowerShell/ConsoleGuiTools

OCGV:Different Filter will "forget" all selected before

MrFly72 opened this issue · 24 comments

Prerequisites

  • Write a descriptive title.
  • Make sure you are able to repro it on the latest version
  • Search the existing issues.

Steps to reproduce

When a filter is active at the end of choosing elements, only the elements that are included in the active filter will be returned.
eg.:
Get-Process | Out-ConsoleGridView
Check one process, eg. Word
Filter by eg.Notepad, check Notepad
When you now hit enter with the active filter for notepad, only notepad will be returned

There is only one workaround this, you have to remove the filter before hitting enter.

This bug is introduced in the newer version, as before, hitting enter in a filtered list, would gather all elements that have been checked.

Expected behavior

Word + Notepad should be returned

Actual behavior

Only notepad is returned

Error details

No Error ourput

Environment data

Name                           Value
----                           -----
PSVersion                      7.2.6
PSEdition                      Core
GitCommitId                    7.2.6
OS                             Linux 5.15.56-v8+ #1575 SMP PREEMPT Fri Jul 22 20:31:26 BST 2022
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Version

0.7.2

Visuals

No response

tig commented

This is caused by #163

I agree this is a change in behavior and it's a bummer it impacted you.

I think it's too late to revert/fix this for 0.7.2 as @andschwa notes.

We can definitely fix for 0.7.3.

The question is, how do I fix it?

See #121 for more background.

I want to describe my impact on this a little bit more in detail.
I am using OCGV on a Raspberry Pi for a script I wrote to automate Media Download from State TV.
Basically it filters series etc. by rest-api from a source-page, then displays them with OCGV to check for shows to be downloaded.
To easier check them, as it is usually a list of 1800 shows, I filter them, eg. "Show 1", then check the ones to download, then filter by "show 2" and mark others to download and so on.
at the end, i press enter to accept all shows and then the script will add download jobs on my NAS by rest-api.
it will wait for all shows to download and rename them by defined pattern (eg. Date-Series.Title-Episode-Title.mp4).
I know, that the Windows Version of OGV, also does not "keep" marked entries by "CTRL", but on the other end there are no checkboxes, so totally different approach.

For me it would be valuable, for the checkmarks to be persistent through filters.
At the moment, the workaround for me is, to remove the filter before "enter", as the checkmarks will persist.
The only bummer is, that you really have to clear filter by "backspace" character by character

BDisp commented

The only bummer is, that you really have to clear filter by "backspace" character by character

The Filter has a ContextMenu with a Delete All where you can delete all text at once.

How do I reach the context menu on Linux shell?
Did not find any possibility in an ssh shell

BDisp commented

How do I reach the context menu on Linux shell? Did not find any possibility in an ssh shell

By mouse right clicking on the TextField or by pressing Ctrl+Shift+D. But I see that this isn't working on the current build. I submitted this pr gui-cs/Terminal.Gui#1968 to allow pressing Ctrl+R, because Linux don't differentiate Ctrl+alfa from Ctrl+Shift+alfa.

Mouse? Hehe. Don't use one on my iPad which connects via SSH to the raspian shell and then use the shell to start pwsh.
So keyboard is essential for this.

BDisp commented

Mouse? Hehe. Don't use one on my iPad which connects via SSH to the raspian shell and then use the shell to start pwsh. So keyboard is essential for this.

I forgot to mention that the context menu can be opened with the keyboard by pressing Shift+F10, but I don't know why it isn't opening with the current build.

Ok. I mean I can understand that some people want it this way (Filter will forget all previously checked).
As in the thread which changed this was mentioned, there are people who want his behavior and some don't. This is a typical area for a switch. Default could be "drop selections" and a switch like -keepselectsonfilter could keep them.

I must realize, that I more then once walked into this issue, even after knowing that it changed.
HAd this great way before:

  • Filter --> Select
  • Filter something else --> Select
  • ....
  • hit enter and go.
    now the way is to get back to "without filter" first and then hit enter, and I forget that pretty much all the time.
    Additionally to that, this change is also not complety thought through, as the elements keep checked and when you get back to "no filter", the ones from before the filter are still checked.
    I think it really needs a switch like "Keep selected on filter change" which should also take all into count on pressing enter.
    and if the switch is not set, it would also forget the selected from before the filter.
    But nevertheless I think this would be time for a gui-enhancement, too.
    there could be a couple of values: #selected in this filter + #selected total.

Would a solution be to 'pin' selected items regardless of filter? So if an item is checked then it doesn't disappear even when the filter is changed? That should make clear that the ticked items are going to be confirmed even if they don't match the filter?

Sort of like this:
pinningmultiselect
Ignore the random reorder of items as they are ticked ;)

Apologies if I have misunderstood the issue.

Would also be ok in my eyes.
And I think the counter of how many are selected is also not a bad idea.

BDisp commented

That is the best solution. Maintaining a track on each new filter to the ID of all the available items from the empty filter.

Is someone actively working on this?
I must really admit that I really often "pitfall" into this.
Filter, check some element, filter something else, check some additional and then forget to delete filters and will only have the elements with the checked ones in the second filter.
Btw. I use this in a list with about 2000items, where without filtering, it is not really nice to select.
A solution would be very welcome!

tig commented

I def want to fix this!

I will get to it asap.

Any news?
Meanwhile i get used to

  • filter
  • select
  • different filter
  • select
  • ...
  • don't forget to unfilter before enter or you loose Checked elements
tig commented

No update at this time. On my list to work on but been super busy. Sorry.

Any news on this?

tig commented

@MrFly72, whatcha think of this?

xsK3sKz 1

The model is now:

  • The input list is truth.
  • Mark/Unmarked get applied to input.
  • The ListView always shows the filtered list + any items in the input list that were marked

Thanks to @tznind for the suggestion.

Looks great. Can tell you how it feels when able to try.

tig commented

Putting @MrFly72's question in right thread:

One first question. How does it behave if the screen eg. Only shows 20 elements and I have already selected 18. is the scrolling area then still 20 and the pinned elements will "walk up" in the list or are place 1-18 fix with the pinned elements and only the lines 19-20 will move?

The pinned elements currently are just the top elements in the filtered list. They scroll with the list.

Making them actually be pinned (so they don't scroll) would be a big change...

Hi.
I am testing in every day usage and found out, that the elements will not be on top of list, they will be in the same order, that they would have been in the "no-filtered" list:
image
Would be "nicer" if they would really be at the top. Or what do you think ?

tig commented

That was my intent. I'll look to see what I did wrong.

tig commented

#188 should fix this! Let me know (in that PR comments).