Allow the auto-complete listing to work when given a list that is not alphabetically sorted (ex. sorted by priority).
I could understand a variant of autocompletion lists that allowed arbitrary orderings and worked by eliminating non-matching choices but this retains non-matching items so the context provided by the list is not really useful.
If there are a lot of correct matches (ex. this situation), certain ones should be placed first (because they are more likely to be used), however, the other items cannot necessarily always be eliminated.
(For pruning the choices, Code::Blocks rebuilds the list every x number of characters typed.)
..\src\AutoComplete.cxx(127) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
cmp = lenA - lenB;
There are some performance concerns here: a potentially expensive sort is being performed where it wasn't before and clients have no way to turn this off. Unnecessary work is being performed: Sorter::operator() is stripping off image IDs when they are not returned from AutoComplete::GetValue.
AutoComplete::GetValue is retrieving values from the GUI layer's list box implementation which may be expensive, depending on platform. It creates extra std::string objects which is fine for returning a single item when selected by the user but is not so great when in the middle of a comparison function.
It would allow client choice to add another setting like SCI_AUTOCSETSORT with an enumerated value indicating if it is to be assumed sorted or not. Could be extended in the future to automatically sort the values. May also be faster and minimize platform-dependencies to perform the sort on the raw data instead of retrieving it from the platform layer.
Okay; I will rework the patch to attempt to address these points.
(Earlier, I was have some issues when I did not strip the image IDs, but now that I tested removing them again, the problem does not seem to have returned... ?!)
This patch utilizes the raw data for sorting. It also adds a member variable autoSort to determine if it should assume presorted, sort internally (list remains in original order), or actually sort the list. (I was not able to make sense of how to hook this up to Scintilla's settings structure, so that still needs to be implemented.)
Minor optimizations of last patch.
This isn't portable:
+ int len = strlen(list);
+ char sortedList[len + 1];
../src/AutoComplete.cxx:164:25: warning: ISO C++ forbids variable length array 'sortedList' [-Wvla]
You can use a vector<char> or similar.
There needs to be an explanation of what this mode does that can go in the documentation. "sort internally (do not change the actual order)" will just cause support questions.
I am using -Wall and -Wextra; what other warning flags do you use?
Log in to post a comment.
Sign up for the SourceForge newsletter:
You seem to have CSS turned off.
Please don't fill out this field.