Permalink
Browse files

better completion (see below)

When there are multiple matches in one line the first will be used, not the last
  • Loading branch information...
1 parent 417192e commit e58f610dd295bea7da14d2deed7270d6105c18ff @Vifon committed Feb 16, 2012
Showing with 2 additions and 10 deletions.
  1. +2 −10 autocomplete-ALL-the-things
@@ -67,19 +67,11 @@ sub getCurrentWord {
sub findMatchingWord {
my ($self, $toMatch, $row) = @_;
-
- for (my $i = $row-1; $i >= 0; --$i) {
- $_ = $self->ROW_t($i);
- if (/\b${toMatch}\w/i) {
- s/^.*\b$toMatch(\w+).*$/$1/i;
- return $_;
- }
- }
- for (my $n = 1; $n <= 2; ++$n) {
+ for (my $n = 0; $n <= 2; ++$n) {
for (my $i = $row-1; $i >= 0; --$i) {
$_ = $self->ROW_t($i);
if (/\b${toMatch}\W{$n}\w/i) {
- s/^.*\b$toMatch(\W{$n}\w+).*$/$1/i;
+ s/^.*?\b$toMatch(\W{$n}\w+).*$/$1/i;
return $_;
}
}

0 comments on commit e58f610

Please sign in to comment.