This repository was archived by the owner on Dec 15, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Refactor Search.output() from callback to iterator pattern #4
Draft
Copilot
wants to merge
9
commits into
main
Choose a base branch
from
copilot/refactor-output-iterator
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Co-authored-by: hzhangxyz <[email protected]>
Co-authored-by: hzhangxyz <[email protected]>
Co-authored-by: hzhangxyz <[email protected]>
Copilot
AI
changed the title
[WIP] Refactor search output to use iterator pattern
Refactor Search.output() from callback to iterator pattern
Dec 12, 2025
hzhangxyz
suggested changes
Dec 12, 2025
Member
hzhangxyz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不是这么写的, 你现在这样是一股脑把execute写完了, 我希望你能让我execute中的每步都可能暂时先break出来.
Co-authored-by: hzhangxyz <[email protected]>
Contributor
Author
已修复。现在每次迭代只处理execute中的一个结果,callback立即返回true来暂停。如果外部break,下次调用output()会继续执行新的execute()调用。 commit: 5e9fbef |
Co-authored-by: hzhangxyz <[email protected]>
Co-authored-by: hzhangxyz <[email protected]>
hzhangxyz
suggested changes
Dec 12, 2025
Member
hzhangxyz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return true会破坏数据结构, 你只能return false, 我希望你使用callback或者promise, iterator之类的方式实现. 现在这个版本完全不能使用.
Co-authored-by: hzhangxyz <[email protected]>
Contributor
Author
已修复。现在callback始终返回false以保持数据结构完整性。实现方式:
commit: a979241 |
Co-authored-by: hzhangxyz <[email protected]>
3018818 to
dcb0d14
Compare
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
output()method required callers to pass a callback that must returnfalseto continue iteration, making it error-prone and verbose. This refactors it to use generator pattern for cleaner iteration.Changes
output()to generator function returningGenerator<string>setupSearchLoop()to usefor...ofloopfalseto maintain data structure (returningtruewould break it)output()call before callingexecute()againExample
Before:
After:
Behavior
output()first yields any pending results from a previous call (if iteration was interrupted)execute()with a callback that always returnsfalseto collect all available resultspendingResultsstores buffered results andcurrentIndextracks positionfalsefrom the callbackOriginal prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.