getCurrentSuggestion(); if ($suggestion === null) { return false; } // Word-accept currently supports append-only suggestions. if (!$suggestion->isAppendOnly($buffer->getCursor())) { return false; } $text = $suggestion->getAcceptText(); $wordEnd = (new WordNavigationPolicy())->findNextWord($text, 0); $firstWord = \mb_substr($text, 0, $wordEnd); if ($firstWord === '') { return false; } $buffer->insert($firstWord); $readline->clearSuggestion(); return true; } /** * {@inheritdoc} */ public function getName(): string { return 'accept-suggestion-word'; } }