#981 AutoComp: allow non-alphabetical sort

Completed
closed
Neil Hodgson
scintilla (39)
4
2013-04-12
2013-03-02
Alpha
No

Allow the auto-complete listing to work when given a list that is not alphabetically sorted (ex. sorted by priority).

1 Attachments

Discussion

1 2 3 4 > >> (Page 1 of 4)
  • Neil Hodgson
    Neil Hodgson
    2013-03-02

    • labels: --> scintilla
    • assigned_to: Neil Hodgson
    • priority: 5 --> 4
     
  • Neil Hodgson
    Neil Hodgson
    2013-03-02

    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.

     
  • Alpha
    Alpha
    2013-03-02

    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.)

     
  • Neil Hodgson
    Neil Hodgson
    2013-03-05

    ..\src\AutoComplete.cxx(127) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
    cmp = lenA - lenB;

     
  • Neil Hodgson
    Neil Hodgson
    2013-03-05

    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.

     
  • Alpha
    Alpha
    2013-03-05

    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... ?!)

     
  • Alpha
    Alpha
    2013-03-06

    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.)

     
    Attachments
  • Alpha
    Alpha
    2013-03-06

    Minor optimizations of last patch.

     
    Attachments
  • Neil Hodgson
    Neil Hodgson
    2013-03-06

    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.

     
  • Alpha
    Alpha
    2013-03-06

    I am using -Wall and -Wextra; what other warning flags do you use?

     
1 2 3 4 > >> (Page 1 of 4)