fix: recurse into nested child tabs in DocsService#218
fix: recurse into nested child tabs in DocsService#218allenhutchison wants to merge 2 commits intomainfrom
Conversation
The Google Docs API returns tabs as a tree structure where each tab can have childTabs. getText, appendText, and replaceText only iterated the top-level array, silently ignoring nested child tabs. Add a recursive _flattenTabs helper that walks the tab tree depth-first and returns a flat array. Update all three methods to use it. Fixes #207
Summary of ChangesHello @allenhutchison, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a limitation where the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request effectively addresses the issue of nested child tabs not being processed in DocsService. The introduction of the _flattenTabs helper is a clean solution, and applying it to getText, appendText, and replaceText ensures consistent behavior. The new tests are comprehensive and cover the nested tab scenarios well, confirming the fix. I have one suggestion to make the _flattenTabs implementation even more concise and idiomatic.
Problem
Fixes #207
The Google Docs API returns tabs as a tree structure where each tab can have
childTabs. The current code only iterates the top-levelres.data.tabsarray, so nested (child) tabs are silently ignored.Affected methods:
getText,appendText,replaceText.Solution
Added a recursive
_flattenTabshelper that walks the tab tree depth-first and returns a flat array. Updated all three methods to use it (one-line change each).Tests
Added 4 new test cases covering nested child tab scenarios:
getText— includes text from nested child tabsgetText— finds a child tab by tabIdappendText— appends to a nested child tab by tabIdreplaceText— replaces text in a nested child tab by tabIdAll 390 tests pass across 25 suites.