MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / yankPop

Method yankPop

packages/pi-tui/src/components/input.ts:320–336  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

318 }
319
320 private yankPop(): void {
321 if (this.lastAction !== "yank" || this.killRing.length <= 1) return;
322
323 this.pushUndo();
324
325 // Delete the previously yanked text (still at end of ring before rotation)
326 const prevText = this.killRing.peek() || "";
327 this.value = this.value.slice(0, this.cursor - prevText.length) + this.value.slice(this.cursor);
328 this.cursor -= prevText.length;
329
330 // Rotate and insert new entry
331 this.killRing.rotate();
332 const text = this.killRing.peek() || "";
333 this.value = this.value.slice(0, this.cursor) + text + this.value.slice(this.cursor);
334 this.cursor += text.length;
335 this.lastAction = "yank";
336 }
337
338 private pushUndo(): void {
339 this.undoStack.push({ value: this.value, cursor: this.cursor });

Callers 1

handleInputMethod · 0.95

Calls 3

pushUndoMethod · 0.95
peekMethod · 0.80
rotateMethod · 0.45

Tested by

no test coverage detected