MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / executeReplace

Function executeReplace

source code/vim/operators.ts:201–219  ·  view source on GitHub ↗
(
  char: string,
  count: number,
  ctx: OperatorContext,
)

Source from the content-addressed store, hash-verified

199 * Execute replace character (r command).
200 */
201export function executeReplace(
202 char: string,
203 count: number,
204 ctx: OperatorContext,
205): void {
206 let offset = ctx.cursor.offset
207 let newText = ctx.text
208
209 for (let i = 0; i < count && offset < newText.length; i++) {
210 const graphemeLen = firstGrapheme(newText.slice(offset)).length || 1
211 newText =
212 newText.slice(0, offset) + char + newText.slice(offset + graphemeLen)
213 offset += char.length
214 }
215
216 ctx.setText(newText)
217 ctx.setOffset(Math.max(0, offset - char.length))
218 ctx.recordChange({ type: 'replace', char, count })
219}
220
221/**
222 * Execute toggle case (~ command).

Callers 2

fromReplaceFunction · 0.85
replayLastChangeFunction · 0.85

Calls 2

firstGraphemeFunction · 0.85
maxMethod · 0.80

Tested by

no test coverage detected