Developer forums (C::B DEVELOPMENT STRICTLY!) > CodeCompletion redesign

Code completion with partial matching

<< < (6/9) > >>

Alpha:

--- Quote from: Alpha on April 11, 2014, 08:49:21 pm ---(Improvements to stability/usability are in progress...)

--- End quote ---
Updated patch (attached) is fully functional, and stable (as far as I can tell) edit: discovered a crash to work out.


--- Quote from: Alpha on January 19, 2014, 10:01:31 pm ---
--- Quote from: dmoore on January 19, 2014, 07:13:08 am ---a very nice hack indeed. Works beautifully.

--- End quote ---
Until you try to complete wxString.  With my clang plugin, it does not even show up until I have typed the full name, and even then, it is the fifth item. ???

--- End quote ---
Also included in this patch is a potential solution to this.  CCManager records each time you select (hit enter/double click to complete and insert the result) an item that took "too long" to come up in the autocomplete listing.  These entries (stored in a small buffer, to allow older, no longer used, entries to expire) are given a score bonus, so they float to the top faster the next time the same query comes up.

After a bit more testing, and adding the appropriate configuration menu, this feature should be ready to commit.

Alpha:

--- Quote from: Alpha on April 12, 2014, 02:52:32 am ---[...] stable (as far as I can tell) edit: discovered a crash to work out.

--- End quote ---
Probably working now ::)... (patch attached)

dmoore:
While i can see some utility in this approach, to be honest I would prefer something more deterministic. What is the issue with implementing the algorithm I proposed above?

Alpha:

--- Quote from: dmoore on April 12, 2014, 05:11:07 am ---What is the issue with implementing the algorithm I proposed above?

--- End quote ---
Mostly it was that this "adaption" algorithm was much faster for me to get to a working state.  (To implement your algorithm, I would need to spend some trial-error time, testing different constants.)

Although determinism is, in general, preferential (to me as well), in using this completion algorithm, it bothers me each time something takes longer than with plain alphabetical.  I doubt I could come up with any deterministic algorithm to sufficiently satisfy myself.
That said, there is an easy point in the code to disable adaption, so it can be a configurable option.

Alpha:

--- Quote from: Alpha on April 12, 2014, 05:58:18 am ---
--- Quote from: dmoore on April 12, 2014, 05:11:07 am ---What is the issue with implementing the algorithm I proposed above?

--- End quote ---
[...]  To implement your algorithm, I would need to spend some trial-error time, testing different constants.

--- End quote ---
This seems to work reasonably... (I will need to do more testing though.)

--- Code: ---    static int CalcPrefixValue(wxString query, wxString token)
    {
        if (query.IsEmpty() || token.IsEmpty())
            return 0;

        int val = 0;
        int shift = sizeof(val) * 8 - 2;

        if (!token.Lower().StartsWith(query.Lower()))
            val += (1 << shift);
        --shift;

        if (!token.StartsWith(query))
            val += (1 << shift);
        --shift;

        int idx = token.Lower().Find(query.Lower());
        if (idx == wxNOT_FOUND)
            val += (1 << shift);
        --shift;
        if (idx > 6)
            val += (1 << shift);
        --shift;
        if (idx > 3)
            val += (1 << shift);
        --shift;

        idx = token.Find(query);
        if (idx == wxNOT_FOUND)
            val += (1 << shift);
        --shift;
        if (idx > 6)
            val += (1 << shift);
        --shift;
        if (idx > 3)
            val += (1 << shift);
        --shift;

        val += (1 << shift);

        val *= std::max<int>(1, 4 - query.Length());

        return val; // lower is better
    }

--- End code ---

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version