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

Function findQuoteObject

source code/vim/textObjects.ts:120–149  ·  view source on GitHub ↗
(
  text: string,
  offset: number,
  quote: string,
  isInner: boolean,
)

Source from the content-addressed store, hash-verified

118}
119
120function findQuoteObject(
121 text: string,
122 offset: number,
123 quote: string,
124 isInner: boolean,
125): TextObjectRange {
126 const lineStart = text.lastIndexOf('\n', offset - 1) + 1
127 const lineEnd = text.indexOf('\n', offset)
128 const effectiveEnd = lineEnd === -1 ? text.length : lineEnd
129 const line = text.slice(lineStart, effectiveEnd)
130 const posInLine = offset - lineStart
131
132 const positions: number[] = []
133 for (let i = 0; i < line.length; i++) {
134 if (line[i] === quote) positions.push(i)
135 }
136
137 // Pair quotes correctly: 0-1, 2-3, 4-5, etc.
138 for (let i = 0; i < positions.length - 1; i += 2) {
139 const qs = positions[i]!
140 const qe = positions[i + 1]!
141 if (qs <= posInLine && posInLine <= qe) {
142 return isInner
143 ? { start: lineStart + qs + 1, end: lineStart + qe }
144 : { start: lineStart + qs, end: lineStart + qe + 1 }
145 }
146 }
147
148 return null
149}
150
151function findBracketObject(
152 text: string,

Callers 1

findTextObjectFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected