fix: made the text cursor height change between different font sizes#422
fix: made the text cursor height change between different font sizes#422justinedagreat wants to merge 5 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughCursor rendering now computes the SVG cursor box from the selected span's fontSize and the line baseline, returning early if fontSize is absent; width stays fixed and bottom padding is proportional to font size. ChangesCursor Rendering Geometry
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsStopped waiting for pipeline failures after 30000ms. One of your pipelines takes longer than our 30000ms fetch window to run, so review may not consider pipeline-failure results for inline comments if any failures occurred after the fetch window. Increase the timeout if you want to wait longer or run a Comment |
…en-different-font-sizes
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
frontend/src/features/authoring/text/Cursor.tsx (1)
27-27: 💤 Low valueConsider extracting the bottom padding multiplier to a named constant.
The
0.25multiplier for cursor bottom padding is a magic number without explanation. Extracting it to a named constant would improve code clarity.♻️ Proposed refactor
+ const CURSOR_BOTTOM_PADDING_RATIO = 0.25; + function Cursor({ bounds }: { bounds: RelativeBounds }) { // ... const span = line.spans[start.spanI]; const cursorHeight = span.style.fontSize; - const cursorBottomPadding = span.style.fontSize * 0.25; + const cursorBottomPadding = span.style.fontSize * CURSOR_BOTTOM_PADDING_RATIO;🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@frontend/src/features/authoring/text/Cursor.tsx` at line 27, The magic number 0.25 used to compute cursorBottomPadding should be extracted to a named constant to improve clarity; introduce a descriptive constant (e.g., CURSOR_BOTTOM_PADDING_MULTIPLIER) near the top of Cursor.tsx and replace the literal in the calculation of cursorBottomPadding (the expression using span.style.fontSize * 0.25) with span.style.fontSize * CURSOR_BOTTOM_PADDING_MULTIPLIER, keeping the numeric value the same and optionally adding a short comment explaining its purpose.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@frontend/src/features/authoring/text/Cursor.tsx`:
- Around line 25-27: The cursor rendering reads line.spans[start.spanI] without
checks and then accesses span.style.fontSize, which can throw if start.spanI is
out of range or span.style is missing; update Cursor.tsx to defensively fetch
the span (check that line.spans exists and start.spanI is within bounds) and
guard span.style before reading fontSize, using a sensible default fontSize
(e.g., 14) when absent; compute cursorHeight and cursorBottomPadding from this
safeFontSize and keep behavior consistent with getVisualPosition’s handling of
missing spans.
---
Nitpick comments:
In `@frontend/src/features/authoring/text/Cursor.tsx`:
- Line 27: The magic number 0.25 used to compute cursorBottomPadding should be
extracted to a named constant to improve clarity; introduce a descriptive
constant (e.g., CURSOR_BOTTOM_PADDING_MULTIPLIER) near the top of Cursor.tsx and
replace the literal in the calculation of cursorBottomPadding (the expression
using span.style.fontSize * 0.25) with span.style.fontSize *
CURSOR_BOTTOM_PADDING_MULTIPLIER, keeping the numeric value the same and
optionally adding a short comment explaining its purpose.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 92ff02c6-5b99-4785-b016-6299d21f091d
📒 Files selected for processing (1)
frontend/src/features/authoring/text/Cursor.tsx
…font-sizes' of github.com:UoaWDCC/VPS into vps-43-textbox-line-height-unchanged-between-different-font-sizes
Issue
The text cursor is not changing size when there are multiple text sizes in a text box.
Solution
Retrieve the current text span and use its fontSize to determine the cursor height.
Risk
Low, because it only affects the rendering of the cursor. It should not affect text data or editing functionality
Checklist
Summary by CodeRabbit