#981 AutoComp: allow non-alphabetical sort

Completed
closed
Neil Hodgson
scintilla (44)
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 3 of 4)
  • Neil Hodgson
    Neil Hodgson
    2013-03-20

    That is working better but there are still some problems. There are two parallel data structures here: the visual list and the sorted index and they need to be synchronized. One problem occurs if there is an empty entry in the list - the data structures aren't synchronized and it asserts out inside std::vector. Try this call in mode SC_ORDER_CUSTOM

    wEditor.CallString(SCI_AUTOCSHOW, 1, "aardvark\n\nant");
    

    and (with Visual Studio 2012) there'll be an assertion:

    ---------------------------
    Microsoft Visual C++ Runtime Library
    ---------------------------
    Debug Assertion Failed!
    
    Program: C:\Windows\system32\MSVCP110D.dll
    File: C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\vector
    Line: 1140
    
    Expression: vector subscript out of range
    

    Looking for problems with desynchronization can be made simplaer by adding another assertion to check that they are, at least, the same length. Just after the call to SetList for SC_ORDER_CUSTOM:

    PLATFORM_ASSERT(lb->Length() == sortMatrix.size());
    
     
  • Alpha
    Alpha
    2013-03-20

    That is a problem because the wxScintilla/wxSTC implementation discards empty entries:

    void ListBoxImpl::SetList(const char* list, char separator, char typesep)
    {
        GETLB(wid)->Freeze();
        Clear();
        wxStringTokenizer tkzr(sci2wx(list), (wxChar)separator);
        while ( tkzr.HasMoreTokens() ) {
            wxString token = tkzr.GetNextToken();
            long type = -1;
            int pos = token.Find(typesep);
            if (pos != -1) {
                token.Mid(pos+1).ToLong(&type);
                token.Truncate(pos);
            }
            Append(token, (int)type);
        }
        GETLB(wid)->Thaw();
    }
    

    How should Scintilla handle empty entries?

     
    • Neil Hodgson
      Neil Hodgson
      2013-03-20

      Modifying other platform layers to remove empty entries to match wxScintilla would be more work than changing wxScintilla. Its likely SC_ORDER_CUSTOM will lead to more formatting including non-selectable headers and blank lines.

      It should be possible to change wxScintilla to be the same as other platforms using wxTOKEN_RET_EMPTY in the tokenizer constructor.

       
  • Alpha
    Alpha
    2013-03-20

    Although, keeping empty entries in the sorted index can be done by switching the line:
    while (list[i] == ac->GetSeparator())
    to:
    if (list[i] == ac->GetSeparator())

     
    Attachments
    • Neil Hodgson
      Neil Hodgson
      2013-03-20

      Makes no difference. The first \n was consumed earlier in the loop so changing from while to if does not preserve the second \n.

       
  • Alpha
    Alpha
    2013-03-21

    Oops, sorry; overlooked that ++i (it was a previous optimization under the assumption of non-zero length entries). Removing it results in correct behaviour. (Adding wxTOKEN_RET_EMPTY to wxScintilla matches this behaviour.)

     
    Attachments
  • Alpha
    Alpha
    2013-03-21

    Except... what is the expected value of a terminating separator?
    "aardvark\n\nant"
    gives three tokens:
    'aardvark', '', 'ant'

    but what should
    "aardvark\n\nant\n"
    do? Three tokens as well:
    'aardvark', '', 'ant'
    or four tokens:
    'aardvark', '', 'ant', ''

    (And what about "aardvark\n\nant\n\n"?)

     
    • Neil Hodgson
      Neil Hodgson
      2013-03-22

      For compatibility with current behaviour, a single trailing \n should be ignored.

      BTW, there is currently an error downloading patch 9 so I'll try again later.

       
  • Neil Hodgson
    Neil Hodgson
    2013-03-22

    Still seeing "Error 500" for patch 9 so could you please upload it again. Probably prudent to use a different name.

     
    Last edit: Neil Hodgson 2013-03-22
  • Alpha
    Alpha
    2013-03-23

    Strange... let's see if this works.

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