4 ms·
For those that are curious how the autocorrect does its magic, here is the code https://github.com/git/git/blob/master/help.c#L293 https://github.com/git/git/bl
by keeperofdakeys 13y ago
For those that are curious how the autocorrect does its magic, here is the code https://github.com/git/git/blob/master/help.c#L293 https://github.com/git/git/blob/master/help.c#L293.
The most important part of the algorithm is the line "levenshtein(cmd, candidate, 0, 2, 1, 3) + 1;". This calculates the levenshtein distance between what you typed and valid commands, using different weights for different types of manipulations. In this case, 0 for swaps, 2 for substitutions, 1 for adds and 3 for deletes.