(string)
| 680 | } |
| 681 | |
| 682 | function reset(string) { |
| 683 | isInReverseSearch = string !== undefined; |
| 684 | |
| 685 | // In case the reverse search ends and a history entry is found, reset the |
| 686 | // line to the found entry. |
| 687 | if (!isInReverseSearch) { |
| 688 | if (lastMatch !== -1) { |
| 689 | repl[kSetLine](repl.history[lastMatch]); |
| 690 | repl.cursor = lastCursor; |
| 691 | repl.historyIndex = lastMatch; |
| 692 | } |
| 693 | |
| 694 | lastMatch = -1; |
| 695 | |
| 696 | // Clear screen and write the current repl.line before exiting. |
| 697 | cursorTo(repl.output, promptPos.cols); |
| 698 | moveCursor(repl.output, 0, promptPos.rows); |
| 699 | clearScreenDown(repl.output); |
| 700 | if (repl.line !== '') { |
| 701 | repl.output.write(repl.line); |
| 702 | if (repl.line.length !== repl.cursor) { |
| 703 | const { cols, rows } = repl.getCursorPos(); |
| 704 | cursorTo(repl.output, cols); |
| 705 | moveCursor(repl.output, 0, rows); |
| 706 | } |
| 707 | } |
| 708 | } |
| 709 | |
| 710 | input = string || ''; |
| 711 | cursor = -1; |
| 712 | historyIndex = repl.historyIndex; |
| 713 | alreadyMatched.clear(); |
| 714 | } |
| 715 | |
| 716 | function reverseSearch(string, key) { |
| 717 | if (!isInReverseSearch) { |
no test coverage detected
searching dependent graphs…