nightroman/FarNet

TabExpansion2 v1.0.1 regression on read only results

nightroman opened this issue · 0 comments

v1.0.1 uses the work around read only results borrowed from TabExpansionPlusPlus:

if ($result.CompletionMatches.IsReadOnly) {
    $private:collection = New-Object System.Collections.ObjectModel.Collection[System.Management.Automation.CompletionResult]
    foreach($_ in $result.CompletionMatches) {
        $collection.Add($_)
    }
    $result.GetType().GetProperty('CompletionMatches').SetValue($result, $collection)
}

It works but it makes incorrect ReplacementIndex and ReplacementLength.
E.g. for ... [cmd= as if we are about to replace just =, not [cmd=.
Note that some ... is essential, v1.0.1 works fine for a one-liner [cmd=.