MCPcopy
hub / github.com/codeaashu/claude-code / getSelectedText

Function getSelectedText

src/ink/selection.ts:773–795  ·  view source on GitHub ↗
(s: SelectionState, screen: Screen)

Source from the content-addressed store, hash-verified

771 * with their captured softWrap bits.
772 */
773export function getSelectedText(s: SelectionState, screen: Screen): string {
774 const b = selectionBounds(s)
775 if (!b) return ''
776 const { start, end } = b
777 const sw = screen.softWrap
778 const lines: string[] = []
779
780 for (let i = 0; i < s.scrolledOffAbove.length; i++) {
781 joinRows(lines, s.scrolledOffAbove[i]!, s.scrolledOffAboveSW[i])
782 }
783
784 for (let row = start.row; row <= end.row; row++) {
785 const rowStart = row === start.row ? start.col : 0
786 const rowEnd = row === end.row ? end.col : screen.width - 1
787 joinRows(lines, extractRowText(screen, row, rowStart, rowEnd), sw[row]! > 0)
788 }
789
790 for (let i = 0; i < s.scrolledOffBelow.length; i++) {
791 joinRows(lines, s.scrolledOffBelow[i]!, s.scrolledOffBelowSW[i])
792 }
793
794 return lines.join('\n')
795}
796
797/**
798 * Capture text from rows about to scroll out of the viewport during

Callers 1

copySelectionNoClearMethod · 0.85

Calls 3

selectionBoundsFunction · 0.85
joinRowsFunction · 0.85
extractRowTextFunction · 0.85

Tested by

no test coverage detected