Skip to content

Fix Cursor Positioning (9 test failures) #263

Closed

Description

@malibio

Bug: Cursor Positioning Failures

Related to: Issue #208 (Comprehensive Test Coverage)
Test File: src/tests/integration/cursor-positioning.test.ts
Failures: 9 tests

Problem

Cursor positioning tests are failing across multiple scenarios:

Arrow Navigation Pixel Offset (2 failures)

  • should calculate viewport-relative coordinates with scroll offset
  • should use viewport-relative coordinates not element-relative

Shift+Enter Behavior (4 failures)

  • should not handle Shift+Enter for single-line nodes (headers)
  • should not handle Shift+Enter for single-line nodes (tasks)
  • should use browser insertLineBreak for multiline plain text without formatting
  • should use markdown-aware splitting for inline formatting

Edge Cases (3 failures)

  • should handle empty lines gracefully
  • should handle lines with only whitespace
  • should handle cursor at very end of line

Root Causes

Likely issues:

  1. Viewport-relative vs element-relative coordinate calculation bugs
  2. Shift+Enter handler not checking node type correctly (single-line vs multiline)
  3. Edge case handling for empty content, whitespace, and line boundaries
  4. Markdown-aware line splitting not working correctly

Acceptance Criteria

  • All 9 cursor positioning tests pass
  • Arrow navigation uses correct viewport-relative coordinates
  • Scroll offset properly accounted for
  • Shift+Enter respects node type (no line breaks for headers/tasks)
  • Markdown formatting preserved across line breaks
  • Edge cases handled gracefully (empty lines, whitespace, end-of-line)
  • Quality checks pass: bun run quality:fix

Testing

Run: bun run test src/tests/integration/cursor-positioning.test.ts

Estimated Effort

  • Time: 2-3 hours
  • Complexity: Medium (DOM selection API, coordinate math)
  • Risk: Low-Medium (isolated to cursor behavior)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions