MCPcopy Index your code
hub / github.com/nodejs/node / [kInsertString]

Method [kInsertString]

lib/internal/readline/interface.js:659–699  ·  view source on GitHub ↗
(c)

Source from the content-addressed store, hash-verified

657 }
658
659 [kInsertString](c) {
660 this[kBeforeEdit](this.line, this.cursor);
661 if (!this.isCompletionEnabled) {
662 if (this.cursor < this.line.length) {
663 const beg = StringPrototypeSlice(this.line, 0, this.cursor);
664 const end = StringPrototypeSlice(
665 this.line,
666 this.cursor,
667 this.line.length,
668 );
669 this.line = beg + c + end;
670 } else {
671 this.line += c;
672 }
673 this.cursor += c.length;
674 this[kWriteToOutput](c);
675 return;
676 }
677 if (this.cursor < this.line.length) {
678 const beg = StringPrototypeSlice(this.line, 0, this.cursor);
679 const end = StringPrototypeSlice(
680 this.line,
681 this.cursor,
682 this.line.length,
683 );
684 this[kSetLine](beg + c + end);
685 this.cursor += c.length;
686 this[kRefreshLine]();
687 } else {
688 const oldPos = this.getCursorPos();
689 this.line += c;
690 this.cursor += c.length;
691 const newPos = this.getCursorPos();
692
693 if (oldPos.rows < newPos.rows) {
694 this[kRefreshLine]();
695 } else {
696 this[kWriteToOutput](c);
697 }
698 }
699 }
700
701 async [kTabComplete](lastKeypressWasTab) {
702 this.pause();

Callers

nothing calls this directly

Calls 1

getCursorPosMethod · 0.95

Tested by

no test coverage detected