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

Function findBracketObject

source code/vim/textObjects.ts:151–188  ·  view source on GitHub ↗
(
  text: string,
  offset: number,
  open: string,
  close: string,
  isInner: boolean,
)

Source from the content-addressed store, hash-verified

149}
150
151function findBracketObject(
152 text: string,
153 offset: number,
154 open: string,
155 close: string,
156 isInner: boolean,
157): TextObjectRange {
158 let depth = 0
159 let start = -1
160
161 for (let i = offset; i >= 0; i--) {
162 if (text[i] === close && i !== offset) depth++
163 else if (text[i] === open) {
164 if (depth === 0) {
165 start = i
166 break
167 }
168 depth--
169 }
170 }
171 if (start === -1) return null
172
173 depth = 0
174 let end = -1
175 for (let i = start + 1; i < text.length; i++) {
176 if (text[i] === open) depth++
177 else if (text[i] === close) {
178 if (depth === 0) {
179 end = i
180 break
181 }
182 depth--
183 }
184 }
185 if (end === -1) return null
186
187 return isInner ? { start: start + 1, end } : { start, end: end + 1 }
188}

Callers 1

findTextObjectFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected