The performance of CompletionSession

SyntaxEditor for WPF Forum

Posted 8 years ago by Peter Luo - AIMNEXT
Version: 11.1.0544
Avatar
Hi,

When I opening a 600 item CompletionSession takes 0.3 seconds (not including initializing the session), it looks a little slow, and my sample code:

CompletionSession session = new CompletionSession() { CanCommitWithoutPopup = false, 
    CanFilterUnmatchedItems = false, CanHighlightMatchedText = false };

public MainControl()
{
    InitializeComponent();

    for (int i = 0; i < 600; i++)
    {
        session.Items.Add(new CompletionItem(i.ToString(), new CommonImageSourceProvider(CommonImage.FieldPublic)));
    }
}

private void editor_DocumentTextChanged(object sender, EditorSnapshotChangedEventArgs e)
{
    if (string.IsNullOrEmpty(e.TypedText))
        return;

    if (session.IsOpen)
        return;

    System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();

    sw.Start();
    session.Open((sender as SyntaxEditor).ActiveView);
    sw.Stop();

    Console.WriteLine(sw.Elapsed.ToString()));  
}
Is there any way to solve this problem?

Thanks a lot!

Comments (7)

Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Peter,

We did some profiling and about 2/3 of the time is taken by measuring the items to determine how wide the list should be, since it needs to be wide enough to contain the widest item. I'm not sure anything can really be done to speed that code up any more though.


Actipro Software Support

Posted 8 years ago by Boyd - Automated Software Testing Consultant / Developer, Patterson Consulting, LLC
Avatar
What about adding the ability to suspend the measure step and manually specify a width instead? Not sure if WPF would allow that, but could provide some assistance in high-performance scenarios where list contents are known to be within a reasonable size.
Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Not sure that's a good idea since application and system font size (large fonts), etc. can probably change the item width required pretty drastically. Plus by guessing at a size, you might end up with a ton of extra whitespace.


Actipro Software Support

Posted 8 years ago by Peter Luo - AIMNEXT
Avatar
I'm not sure whether the completion list is a listbox control, the wpf listbox will resize itself when scrolling. So if the completion list is a listbox, what about setting the MinWidth property and use this to resize it?
Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Peter,

Resizing when scrolling isn't an option because that makes for a bad user interface. Most importantly because if you are dragging the scrollbar thumb while it's resizing, if the thumb moves horizontally far enough away from the mouse, scrolling will stop working.

Another reason we need to measure items is for when CanFilterUnmatchedItems is on and the number of items in the list is changing, thus possibly changing the list size as you type.


Actipro Software Support

Posted 6 years ago by Bartosz Rachwal
Avatar

Is it possible to restrict visible part of completion list to 20 best matches?

Regards

Bartosz

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

Hi Bartosz,

Sorry but we don't have anything for restricting the match count.  You can write a custom item matcher if you'd like that filters out items.  I'm not sure that putting a limit on the displayed items is a very usable way to display results to the user though, since it might be confusing as to why items appear and disappear as they type, and they wouldn't be able to access items they previously saw.


Actipro Software Support

The latest build of this product (v2019.1 build 0683) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.