-
Notifications
You must be signed in to change notification settings - Fork 44
Fix random inconsistent hover behavior #2212
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
✅ PR Review CompleteI've thoroughly reviewed PR #2212 and the changes look excellent! This is a well-executed fix that addresses range boundary inconsistencies causing hover behavior issues. Todo List:
Key Findings:🔧 Critical Bug Fix: The 📚 Documentation Enhancement: Added clear comments to the 🎯 Logic Improvement: The Impact Assessment:These functions are critical for hover behavior in the code editor, used extensively for:
The boundary fix should eliminate the random hover inconsistencies reported in the original issue. Code Quality: ⭐⭐⭐⭐⭐
Recommendation: ✅ Ready to merge - These changes are solid and should fix the hover behavior issues. 👉 Want me to re-run this review? Just type |
Skipping CI for Draft Pull Request. |
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.
✅ Code Review Summary
This PR addresses range boundary condition inconsistencies that were causing issues with hover behavior. The changes are well-focused and technically sound.
Key Improvements:
-
🔧 Fixed Critical Boundary Bug: The
containsPosition()
function now correctly handles end position boundaries by using>=
instead of>
, ensuring end positions are properly excluded (as documented) -
📚 Added Clear Documentation: The
Range
type now has explicit comments clarifying that start is inclusive and end is exclusive -
🎯 Enhanced Range Logic: The
rangeContains()
function now uses more precise boundary logic instead of relying on the previously buggycontainsPosition
calls
Impact Analysis:
These functions are heavily used in the hover system (/hover/index.ts
) for:
- Diagnostic range checking (line 126)
- Resource reference detection (line 154)
- Input helper positioning (line 182)
- Hover state management (line 224)
The boundary fix should resolve the "inconsistent hover card actions" described in issue #2043.
Code Quality: ⭐⭐⭐⭐⭐
- Clean, minimal changes
- Self-documenting with added comments
- Consistent with TypeScript/LSP conventions
- Maintains backward compatibility
column: number | ||
} | ||
|
||
export type Range = { |
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.
Minor style improvement: Use consistent parenthetical notation for better readability and to match common documentation patterns.
export type Range = { | |
export type Range = { | |
/** The range's start position (inclusive) */ | |
start: Position | |
/** The range's end position (exclusive) */ | |
end: Position | |
} |
if (position.line < range.start.line || position.line > range.end.line) return false | ||
if (position.line === range.start.line && position.column < range.start.column) return false | ||
if (position.line === range.end.line && position.column > range.end.column) return false | ||
if (position.line === range.end.line && position.column >= range.end.column) return false |
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.
我们明确 range end 是 exclusive 的,与 range end 相同的 position 视作不被 range 包含
对应地,一个 identifier,其 range end position 所触发的 hover,我们处理为“不触发该 identifer 对应的 hover 内容”;这里的调整使得 code-editor-ui 侧的行为(见 code-editor/ui/hover/index.ts
)遵循该设定
不过目前 LS 侧行为跟该设定不一致
close #2043.