MCPcopy Index your code
hub / github.com/codeaashu/claude-code / executeReplace

Function executeReplace

src/vim/operators.ts:199–217  ·  view source on GitHub ↗
(
  char: string,
  count: number,
  ctx: OperatorContext,
)

Source from the content-addressed store, hash-verified

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