How to get the number of filtered items in the completed list?

SyntaxEditor for WPF Forum

Posted 5 months ago by Sunshine - Appeon
Version: 20.1.1
Avatar

After the content of the list is completely filtered, I want to close the prompt window. But I cannot get the number of items in the current list.

My purpose is to prevent the empty prompt window from blocking the line of sight during editing.

Do you have any good suggestions?

Comments (7)

Posted 5 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

There is an ICompletionSession.FilteredItems property that is a collection view of the item currently meeting filter criteria.


Actipro Software Support

Posted 5 months ago by Sunshine - Appeon
Avatar

This list collection does not seem to be filtered until the session is opened.

I want to judge whether there is a project that meets the rules before opening the session, if not, then the session will not be opened.

Calling session.ApplyFilters() before opening does not seem to work.

Posted 5 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

When I did a test here, I activated a filter (via ICompletionFilter.IsActive) and then called ApplyFilters(), all before calling session.Open() and ICompletionSession.FilteredItems.Count returned a filtered count.


Actipro Software Support

Posted 5 months ago by Sunshine - Appeon
Avatar

Sorry for not having a clear description before.

There is no problem filtering through session.FilterItem.

What I want to know is the filtered result entered on the editing interface before opening the session.

For example, my ​​ession.Items contains three options: AAA", "AAB" and "ABC".

I enter the word “B” in the “AA” position of the editor, and the completion list on the editor only shows AAB, but when I open Before the session, the debugging code “session.FilterItems.Count” is still equal to 3.

Of course, after opening the session, the value will become 1.

If I know that the number of items displayed before opening is 0, I will prevent it from opening. Otherwise, it will An empty window pops up, which is not an ideal experience

Posted 5 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

Right, I was saying if you have the filters active and you call session.ApplyFilters() before opening the session, the session.FilteredItems should contain filtered results.  I think you missed doing the session.ApplyFilters() call.


Actipro Software Support

Posted 5 months ago by Sunshine - Appeon
Avatar

By looking at the source code, I found that the filter I need is actually the effect provided by "CompletionSession.dynamicFilter".

"CompletionSession.dynamicFilter" will filter the contents of the list according to the text entered by the current cursor, and then execute the user-defined Filter.

But to complete the Session.dynamicFilter need to use the "session.TypedText" property, otherwise it will not work.

"session.TypedText" only has a value after opening the session.

This is why the filter result of "CompletionSession.dynamicFilter" cannot be obtained before opening the session.

Answer - Posted 5 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Yes that is true, if CanFilterUnmatchedItems is true then dynamicFilter is used.  And that particular filter uses TypedText, which gets initialized on session open to the same value as the text in session.SnapshotRange. 

If you want to filter before the session is opened and have similar results, you could probably call each item matcher programmatically using the session.SnapshotRange.Text instead of session.TypedText as the text.


Actipro Software Support

The latest build of this product (v21.1.2) was released 18 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.