(line, callback)
| 74 | completionsShown = false; |
| 75 | |
| 76 | completer(line, callback) { |
| 77 | const finish = (result) => { |
| 78 | let [completions, matched] = result; |
| 79 | // Nothing to complete if only match is what's already typed |
| 80 | if (completions.length === 1 && completions[0] === matched) |
| 81 | completions = []; |
| 82 | if (completions.length > 1 && !this.completionsShown) { |
| 83 | this._displayCompletions(completions); |
| 84 | } |
| 85 | callback(null, [completions, matched]); |
| 86 | }; |
| 87 | if (this.broken) { |
| 88 | const args = line.trimStart().split(/\s+/); |
| 89 | const cmd = args[0]; |
| 90 | if (cmd === 'print' || cmd === 'p') { |
| 91 | const expr = line.substring(line.indexOf(cmd) + cmd.length).trimLeft(); |
| 92 | if (expr && expr.includes('.')) { |
| 93 | this._expandForCompletion(expr, () => { |
| 94 | finish(this._syncCompleter(line)); |
| 95 | }); |
| 96 | return; |
| 97 | } |
| 98 | if (expr) { |
| 99 | // Expand (..) in globals so built-ins are available for completion |
| 100 | this._expandGlobalPrototype(() => { |
| 101 | finish(this._syncCompleter(line)); |
| 102 | }); |
| 103 | return; |
| 104 | } |
| 105 | } |
| 106 | } |
| 107 | finish(this._syncCompleter(line)); |
| 108 | } |
| 109 | |
| 110 | _displayCompletions(completions) { |
| 111 | const width = process.stdout.columns || 80; |
no test coverage detected