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

Function executeX

src/vim/operators.ts:171–194  ·  view source on GitHub ↗
(count: number, ctx: OperatorContext)

Source from the content-addressed store, hash-verified

169 * Execute delete character (x command).
170 */
171export function executeX(count: number, ctx: OperatorContext): void {
172 const from = ctx.cursor.offset
173
174 if (from >= ctx.text.length) return
175
176 // Advance by graphemes, not code units
177 let endCursor = ctx.cursor
178 for (let i = 0; i < count && !endCursor.isAtEnd(); i++) {
179 endCursor = endCursor.right()
180 }
181 const to = endCursor.offset
182
183 const deleted = ctx.text.slice(from, to)
184 const newText = ctx.text.slice(0, from) + ctx.text.slice(to)
185
186 ctx.setRegister(deleted, false)
187 ctx.setText(newText)
188 const maxOff = Math.max(
189 0,
190 newText.length - (lastGrapheme(newText).length || 1),
191 )
192 ctx.setOffset(Math.min(from, maxOff))
193 ctx.recordChange({ type: 'x', count })
194}
195
196/**
197 * Execute replace character (r command).

Callers 2

handleNormalInputFunction · 0.85
replayLastChangeFunction · 0.85

Calls 4

lastGraphemeFunction · 0.85
isAtEndMethod · 0.80
rightMethod · 0.80
maxMethod · 0.80

Tested by

no test coverage detected