diff --git a/src/Composer/Command/SearchCommand.php b/src/Composer/Command/SearchCommand.php
index a2006eaca..7a25a2294 100644
--- a/src/Composer/Command/SearchCommand.php
+++ b/src/Composer/Command/SearchCommand.php
@@ -60,13 +60,18 @@ EOT
foreach ($repos->getPackages() as $package) {
foreach ($tokens as $token) {
- if (false === ($pos = strpos($package->getName(), $token))) {
+ if (false === ($pos = strpos($package->getName(), $token)) && (false === strpos(join(',',$package->getKeywords() ?: array()), $token))) {
continue;
}
- $name = substr($package->getPrettyName(), 0, $pos)
- . '' . substr($package->getPrettyName(), $pos, strlen($token)) . ''
- . substr($package->getPrettyName(), $pos + strlen($token));
+ if (false !== ($pos = strpos($package->getName(), $token))) {
+ $name = substr($package->getPrettyName(), 0, $pos)
+ . '' . substr($package->getPrettyName(), $pos, strlen($token)) . ''
+ . substr($package->getPrettyName(), $pos + strlen($token));
+ } else {
+ $name = $package->getPrettyName();
+ }
+
$version = $installedRepo->hasPackage($package) ? ''.$package->getPrettyVersion().'' : $package->getPrettyVersion();
$packages[$name][$package->getPrettyVersion()] = $version;