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

Function executeJoin

source code/vim/operators.ts:260–291  ·  view source on GitHub ↗
(count: number, ctx: OperatorContext)

Source from the content-addressed store, hash-verified

258 * Execute join lines (J command).
259 */
260export function executeJoin(count: number, ctx: OperatorContext): void {
261 const text = ctx.text
262 const lines = text.split('\n')
263 const { line: currentLine } = ctx.cursor.getPosition()
264
265 if (currentLine >= lines.length - 1) return
266
267 const linesToJoin = Math.min(count, lines.length - currentLine - 1)
268 let joinedLine = lines[currentLine]!
269 const cursorPos = joinedLine.length
270
271 for (let i = 1; i <= linesToJoin; i++) {
272 const nextLine = (lines[currentLine + i] ?? '').trimStart()
273 if (nextLine.length > 0) {
274 if (!joinedLine.endsWith(' ') && joinedLine.length > 0) {
275 joinedLine += ' '
276 }
277 joinedLine += nextLine
278 }
279 }
280
281 const newLines = [
282 ...lines.slice(0, currentLine),
283 joinedLine,
284 ...lines.slice(currentLine + linesToJoin + 1),
285 ]
286
287 const newText = newLines.join('\n')
288 ctx.setText(newText)
289 ctx.setOffset(getLineStartOffset(newLines, currentLine) + cursorPos)
290 ctx.recordChange({ type: 'join', count })
291}
292
293/**
294 * Execute paste (p/P command).

Callers 2

handleNormalInputFunction · 0.85
replayLastChangeFunction · 0.85

Calls 2

getLineStartOffsetFunction · 0.85
getPositionMethod · 0.80

Tested by

no test coverage detected