MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / renderPositionToOriginal

Function renderPositionToOriginal

cli/src/components/multiline-input.tsx:137–151  ·  view source on GitHub ↗
(text: string, renderPos: number)

Source from the content-addressed store, hash-verified

135
136// Helper to convert render position (in tab-expanded string) to original text position
137function renderPositionToOriginal(text: string, renderPos: number): number {
138 let originalPos = 0
139 let currentRenderPos = 0
140
141 while (originalPos < text.length && currentRenderPos < renderPos) {
142 if (text[originalPos] === '\t') {
143 currentRenderPos += TAB_WIDTH
144 } else {
145 currentRenderPos += 1
146 }
147 originalPos++
148 }
149
150 return Math.min(originalPos, text.length)
151}
152
153type KeyWithPreventDefault =
154 | {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected