Repository navigation
fix(cli): resolve @file:line references and prevent ghost text wrap hang - #29581
Conversation
|
📊 PR Size: size/L
|
Summary of ChangesHello, 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 improves the robustness of the CLI's file resolution logic and UI rendering. It addresses issues where file references with line or range suffixes failed to resolve correctly, and it fixes a potential hang in the input prompt's ghost text wrapping logic under constrained terminal conditions. Highlights
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 the 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 counterproductive. 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. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces robust handling for line, column, and range suffixes (such as :10, :10-20, and #L10-L25) in file paths referenced via @-commands. It adds a utility function stripLineNumberSuffix to strip these suffixes, allowing correct path resolution, permission checks, ignore checks, and glob searches on the base file path. Additionally, it fixes potential hanging issues in the CLI UI's InputPrompt component when wrapping wide characters with very small input widths or when inputWidth is zero. Comprehensive unit tests are added to verify these edge cases. There are no review comments to address, so no further feedback is provided.
Summary
Fixes CLI hangs and resolution failures when referencing files with trailing line numbers or line ranges (e.g.,
@file:10,@file:10-20,@file#L10-L25), and prevents an infinite loop inInputPromptghost text wrapping when terminal width is narrow or contains wide characters.Details
@google/gemini-cli-core):stripLineNumberSuffixinpackages/core/src/utils/atCommandUtils.tsto strip trailing:line,:start-end,:line:col,:line:col-line:col,#L10,#L10-L25,#L10-25, and#L10-#L25suffixes when the literal path does not exist on disk.resolveAtCommandPath(for both relative and absolute paths) andtryExtractPathto resolve the base file path whenfs.statfails withENOENTon a suffixed@filetoken.@google/gemini-cli):checkPermissions,.gitignore/.geminiignorefiltering (shouldIgnoreFile), and the fallbackglobpattern inpackages/cli/src/ui/hooks/atCommandProcessor.tsto usestripLineNumberSuffix(pathName) ?? pathName. This ensures@file:linerespects ignore rules and avoids triggering an expensive recursive**/*file:line*glob scan across workspace directories.@google/gemini-cli):getGhostTextLinesinpackages/cli/src/ui/components/InputPrompt.tsxagainstinputWidth <= 0and ensured the hard-wrap loop (while (stringWidth(wordToProcess) > inputWidth)) always consumes at least one code point when a multi-column character exceedsinputWidth.packages/core/src/utils/atCommandUtils.test.ts,packages/cli/src/ui/hooks/atCommandProcessor.test.ts, andpackages/cli/src/ui/components/InputPrompt.test.tsx.Related Issues
Fixes #19985
How to Validate
@command path resolution,@command processing, andInputPrompt:Pre-Merge Checklist