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

Function applyOperator

src/vim/operators.ts:493–522  ·  view source on GitHub ↗
(
  op: Operator,
  from: number,
  to: number,
  ctx: OperatorContext,
  linewise: boolean = false,
)

Source from the content-addressed store, hash-verified

491}
492
493function applyOperator(
494 op: Operator,
495 from: number,
496 to: number,
497 ctx: OperatorContext,
498 linewise: boolean = false,
499): void {
500 let content = ctx.text.slice(from, to)
501 // Ensure linewise content ends with newline for paste detection
502 if (linewise && !content.endsWith('\n')) {
503 content = content + '\n'
504 }
505 ctx.setRegister(content, linewise)
506
507 if (op === 'yank') {
508 ctx.setOffset(from)
509 } else if (op === 'delete') {
510 const newText = ctx.text.slice(0, from) + ctx.text.slice(to)
511 ctx.setText(newText)
512 const maxOff = Math.max(
513 0,
514 newText.length - (lastGrapheme(newText).length || 1),
515 )
516 ctx.setOffset(Math.min(from, maxOff))
517 } else if (op === 'change') {
518 const newText = ctx.text.slice(0, from) + ctx.text.slice(to)
519 ctx.setText(newText)
520 ctx.enterInsert(from)
521 }
522}
523
524export function executeOperatorG(
525 op: Operator,

Callers 5

executeOperatorMotionFunction · 0.85
executeOperatorFindFunction · 0.85
executeOperatorTextObjFunction · 0.85
executeOperatorGFunction · 0.85
executeOperatorGgFunction · 0.85

Calls 2

lastGraphemeFunction · 0.85
maxMethod · 0.80

Tested by

no test coverage detected