Yaffs site version 1.1
[yaffs-website] / vendor / psy / psysh / src / Psy / TabCompletion / AutoCompleter.php
index a1fcd014a98ca6d288e74a0b2a2ff60b6d1d37ab..86cd1663db3341f83b2f24d688c901d4f2818327 100644 (file)
@@ -52,8 +52,18 @@ class AutoCompleter
      */
     public function processCallback($input, $index, $info = array())
     {
-        $line = substr($info['line_buffer'], 0, $info['end']);
+        // Some (Windows?) systems provide incomplete `readline_info`, so let's
+        // try to work around it.
+        $line = $info['line_buffer'];
+        if (isset($info['end'])) {
+            $line = substr($line, 0, $info['end']);
+        }
+        if ($line === '' && $input !== '') {
+            $line = $input;
+        }
+
         $tokens = token_get_all('<?php ' . $line);
+
         // remove whitespaces
         $tokens = array_filter($tokens, function ($token) {
             return !AbstractMatcher::tokenIs($token, AbstractMatcher::T_WHITESPACE);