Problem with CompletionSession.CanFilterUnmatchedItems

SyntaxEditor for WPF Forum

Posted 14 years ago by Daniel Navarro
Version: 9.2.0511
Platform: .NET 3.5
Environment: Windows Vista (32-bit)
Avatar
Sometimes the completion list window will be wrongly sized.

You can see this problem by making a small modification to your "Sample Browser - Simple Language 5: Completion Provider" sample.

On SimpleCompletionProvider.cs add the following lines to function public override bool RequestSession(IEditorView view, bool canCommitWithoutPopup) ...

// After: CompletionSession sesion = new CompletionSession();

session.CanFilterUnmatchedItems = true; // Filter unmatching items
for (char c = 'A'; c <= 'Z'; c++) // And add a few filler words
{
session.Items.Add(new CompletionItem(c.ToString()+"1", new CommonImageSourceProvider(CommonImage.Keyword)));
session.Items.Add(new CompletionItem(c.ToString()+"2", new CommonImageSourceProvider(CommonImage.Keyword)));
}

Now, run the sample and try the following:

- Go to a new line and type "Z"
> A completion list will show with just "Z1" and "Z2" (all good for now)
- Press backspace (to delete "Z")
> Completion list will show with "U2", "V1", "V2", ... "Z1" (still good)
- Now press "Z" again

> A completion list will show again with "Z1" and "Z2", but this time the window will be wrongly sized

This doesn't happen if you type one of the first letters ("A" to "E"), or if there's just one word on the list starting with the letter you type.

---

PS. I have a related question. If you activate completion provider on new word, and set CanFilterUnmatchedItems = true, then type a non-matching letter (not matching any of the words on the list), you´ll see a "(no items)" window. How could I cancel the CompletionSession when that happens?

Thank you.

Comments (2)

Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Daniel,

This appears to have been caused by the Microsoft ListBox caching its desired size and not always updating, even when its items changed. We added some code in there that should clear the cached value (it's a trick we've had to use in the past for this same issue with Microsoft's implementation) and appears to fix the issue.

As for the other question, right now the UI portion does the filtering. You can get the IntelliPromptCompletionList used for a session by overriding the CompletionSession.CreatePopupContent method. The IntelliPromptCompletionList is only used for a specific session instance, but has a FilteredItems collection. That would be empty if there were no items that matched filter criteria.


Actipro Software Support

Posted 14 years ago by Daniel Navarro
Avatar
That worked! (to cancel the session right after opening it, when FilteredItems was empty) Thank you.
The latest build of this product (v24.1.2) was released 1 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.