Skip to content

Commit 35af106

Browse files
Copilotlpcox
andauthored
refactor: simplify findParentField brace-matching loop and fix joined line in test
Agent-Logs-Url: https://github.com/github/gh-aw-mcpg/sessions/483eafda-7d9e-4972-abe8-062c6a85813e Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
1 parent e2fcfcc commit 35af106

1 file changed

Lines changed: 5 additions & 10 deletions

File tree

internal/proxy/graphql_rewrite.go

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -195,26 +195,21 @@ func findParentField(query string, nodesIdx int) string {
195195
// Walk backward from nodesIdx to find the enclosing `{`
196196
depth := 0
197197
i := nodesIdx - 1
198-
braceFound := false
199198
for i >= 0 {
200199
switch query[i] {
201200
case '{':
202201
if depth == 0 {
203-
braceFound = true
204-
} else {
205-
depth--
202+
goto foundBrace
206203
}
204+
depth--
207205
case '}':
208206
depth++
209207
}
210-
if braceFound {
211-
break
212-
}
213208
i--
214209
}
215-
if !braceFound {
216-
return ""
217-
}
210+
return "" // no enclosing brace found
211+
212+
foundBrace:
218213

219214
// i now points to the `{` of the enclosing block.
220215
// Walk backward past whitespace.

0 commit comments

Comments
 (0)