Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Use sigil in suggestions if specified
  • Loading branch information
lizmat committed Mar 7, 2014
1 parent be9ffea commit 0a173fa
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/Perl6/World.nqp
Expand Up @@ -2363,7 +2363,8 @@ class Perl6::World is HLL::World {
}

method suggest_routines($name) {
$name := "&"~$name unless nqp::substr($name, 0, 1) eq "&";
my $with_sigil := nqp::substr($name, 0, 1) eq "&";
$name := "&" ~ $name unless $with_sigil;
my @suggestions;
my @candidates := [[], [], []];
my &inner-evaluator := make_levenshtein_evaluator($name, @candidates);
Expand All @@ -2379,10 +2380,17 @@ class Perl6::World is HLL::World {
self.walk_symbols(&evaluate);

levenshtein_candidate_heuristic(@candidates, @suggestions);
if !$with_sigil {
my @no_sigils; # can't do in-place $_ alteration
for @suggestions {
nqp::push( @no_sigils, nqp::substr($_,1,nqp::chars($_) - 1) );
}
@suggestions := @no_sigils;
}
if $name eq '&length' {
@suggestions.push: 'chars';
@suggestions.push: 'graphs';
@suggestions.push: 'codes';
@suggestions.push: $with_sigil ?? '&chars' !! 'chars';
@suggestions.push: $with_sigil ?? '&graphs' !! 'graphs';
@suggestions.push: $with_sigil ?? '&codes' !! 'codes';
}
elsif $name eq '&bytes' {
@suggestions.push: '.encode($encoding).bytes';
Expand Down

0 comments on commit 0a173fa

Please sign in to comment.