Changeset View
Changeset View
Standalone View
Standalone View
src/parser/argument/PhutilArgumentSpellingCorrector.php
Show First 20 Lines • Show All 109 Lines • ▼ Show 20 Lines | if ($this->getMode() === self::MODE_COMMANDS) { | ||||
} | } | ||||
} | } | ||||
$input = $this->normalizeString($input); | $input = $this->normalizeString($input); | ||||
foreach ($options as $key => $option) { | foreach ($options as $key => $option) { | ||||
$options[$key] = $this->normalizeString($option); | $options[$key] = $this->normalizeString($option); | ||||
} | } | ||||
// In command mode, accept any unique prefix of a command as a shorthand | |||||
// for that command. | |||||
if ($this->getMode() === self::MODE_COMMANDS) { | |||||
$prefixes = array(); | |||||
foreach ($options as $option) { | |||||
if (!strncmp($input, $option, strlen($input))) { | |||||
$prefixes[] = $option; | |||||
} | |||||
} | |||||
if (count($prefixes) === 1) { | |||||
return $prefixes; | |||||
} | |||||
} | |||||
$distances = array(); | $distances = array(); | ||||
$inputv = phutil_utf8v($input); | $inputv = phutil_utf8v($input); | ||||
foreach ($options as $option) { | foreach ($options as $option) { | ||||
$optionv = phutil_utf8v($option); | $optionv = phutil_utf8v($option); | ||||
$matrix->setSequences($optionv, $inputv); | $matrix->setSequences($optionv, $inputv); | ||||
$distances[$option] = $matrix->getEditDistance(); | $distances[$option] = $matrix->getEditDistance(); | ||||
} | } | ||||
Show All 30 Lines |