Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Words should be sorted with shortest first #7

Open
blokeley opened this issue Jul 14, 2017 · 1 comment
Open

Words should be sorted with shortest first #7

blokeley opened this issue Jul 14, 2017 · 1 comment

Comments

@blokeley
Copy link

Autocomplete is pretty good (thanks for the work) but...

Quite often I'm trying to write a word and Autocomplete suggests words which are much longer than the one I want, and the first few often have "'s" appended, which is seldom what I want.

Indeed, when I just wrote "seldom", it was number 6 on the list, when it should have been number 1 because it was a full valid word in itself.

Is this something that can be implemented? I imagine a sort by ascending length would not take much processing time.

@stophereareyou
Copy link

I used following code in new ahk file to sort wordlist

FileRead, text, WordList.txt
if not ErrorLevel  ; Successfully loaded.
{
    Sort, text, F SortFunc
    FileDelete, WordList.txt
    FileAppend, %text%, WordList.txt
    msgbox % text
    text =  ; Free the memory.
}
SortFunc(lineA, lineB, offset)
{
    ; Return positive if lineA is longer than line B.
    ; Return negative if lineA is shorter than line B.
    if StrLen(lineA) != StrLen(lineB)
        return StrLen(lineA)-StrLen(lineB)
    ; Use offset to try to preserve the order in the file when two lines are of equal length.
    return -offset
}

it sorted the file content in ascending order based on each words length. This works for me.
(tried code from here)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants