MCPcopy Index your code
hub / github.com/codeaashu/claude-code / findQuoteObject

Function findQuoteObject

src/vim/textObjects.ts:118–147  ·  view source on GitHub ↗
(
  text: string,
  offset: number,
  quote: string,
  isInner: boolean,
)

Source from the content-addressed store, hash-verified

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

Callers 1

findTextObjectFunction · 0.85

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected