MCPcopy Create free account
hub / github.com/anus-dev/ANUS / getLineRangeOffsets

Function getLineRangeOffsets

packages/cli/src/ui/components/shared/text-buffer.ts:398–423  ·  view source on GitHub ↗
(
  startRow: number,
  lineCount: number,
  lines: string[],
)

Source from the content-addressed store, hash-verified

396};
397
398export const getLineRangeOffsets = (
399 startRow: number,
400 lineCount: number,
401 lines: string[],
402) => {
403 let startOffset = 0;
404
405 // Calculate start offset
406 for (let i = 0; i < startRow; i++) {
407 startOffset += lines[i].length + 1; // +1 for newline
408 }
409
410 // Calculate end offset
411 let endOffset = startOffset;
412 for (let i = 0; i < lineCount; i++) {
413 const lineIndex = startRow + i;
414 if (lineIndex < lines.length) {
415 endOffset += lines[lineIndex].length;
416 if (lineIndex < lines.length - 1) {
417 endOffset += 1; // +1 for newline
418 }
419 }
420 }
421
422 return { startOffset, endOffset };
423};
424
425export const replaceRangeInternal = (
426 state: TextBufferState,

Callers 1

handleVimActionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected