Question

I am using the ScintillaNET in WPF/C# via the WindowsFormsHost. However, it seems that the control is having an auto-completion problem. I am using a List<string> to hold text to show in the auto-complete drop-down. The variable lang is my List<string> and editor is my ScintillaNET editor:

lang.Add("fprintf");
lang.Add("fscanf");
lang.Add("printf");
lang.Add("scanf");
lang.Add("snprintf");

lang.Add("remove");
lang.Add("rename");
lang.Add("tmpfile");
lang.Add("tmpnam");

lang.Add("fclose");
lang.Add("fflush");
lang.Add("fopen");
lang.Add("freopen");
lang.Add("setbuf");
lang.Add("setvbuf");

editor.AutoComplete.List = lang; 

If I typed printf for example, the drop-down goes to the word printf. However, if I select a word added later in the list, like fopen, the same effect (as with printf) does not happen. The drop-down acts as though the word was not there.

But, the word has been correctly added to the drop-down (as when I scroll down the list), I see fopen there.

Why is the auto-complete box not going to fopen when I typed it, but it goes printf when I typed printf and how can I solve this?

Was it helpful?

Solution

Scintilla likes the list in sorted order. Try doing a

lang.Sort();
editor.AutoComplete.List = lang;

That should do the trick for you.

The underlying Scintilla editor has an Autosort feature, but this is not exposed to the .NET version as far as I can see.

OTHER TIPS

I guess the preferred solution regarding better performance is Torgrim Brochmann'a answer, but you can also make Scintilla do the sort for you:

editor.AutoCOrder = Order.PerformSort;

You only need to set this once and the editor will sort the list for you everytime.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top