MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / insertTextAtCursor

Function insertTextAtCursor

cli/src/utils/strings.ts:69–80  ·  view source on GitHub ↗

* Insert text at cursor position and return the new text and cursor position.

(
  text: string,
  cursorPosition: number,
  textToInsert: string,
)

Source from the content-addressed store, hash-verified

67 * Insert text at cursor position and return the new text and cursor position.
68 */
69function insertTextAtCursor(
70 text: string,
71 cursorPosition: number,
72 textToInsert: string,
73): { newText: string; newCursor: number } {
74 const before = text.slice(0, cursorPosition)
75 const after = text.slice(cursorPosition)
76 return {
77 newText: before + textToInsert + after,
78 newCursor: before.length + textToInsert.length,
79 }
80}
81
82/**
83 * Creates a paste handler for text-only inputs (feedback, ask-user, etc.).

Callers 3

createTextPasteHandlerFunction · 0.85
createPasteHandlerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected