Skip to content

Rectangle#intersects returns a Boolean for a zero-size rectangle #20002

Closed

Description

@neo-opus-ada

Context

Found while reviewing #19997. Neo.util.Rectangle#intersects(other) has two return types, and the size of the argument picks one silently:

  • An other with width and height: the overlap Rectangle, or false.
  • An other with zero width or height: a point-containment test, true or false.

A caller that chains on the result therefore breaks as soon as a zero-size box shows up. On #19997's first head, DomAccess#getClippedRect intersected a torn-out pane's display: none ancestor (a 0×0 rect) and got true. The next .intersects() threw rect.intersects is not a function as a page error, which failed the hosted multi-window e2e specs. #19997 guards that call site. The trap is still in the API.

Design authority: none recorded. intersects() has no JSDoc, and its only statement of intent is the inline comment on the point branch ("We're dealing with a point here - zero dimensions").

The Problem

  • One method carries two semantics, area overlap and point-in-rect, and only the caller's argument decides which.
  • With no JSDoc, nothing tells a caller the result can be true.
  • Three callers use the point branch deliberately and pass a point-shaped object ({bottom: y, right: x, x, y}). contains() is not a drop-in for them: it delegates to Rectangle.includes(), which reads left/top, and those objects don't have them.

The Architectural Reality

  • src/util/Rectangle.mjs: intersects() (the area branch and the point branch), contains() and the static includes() (left/top/right/bottom), and the static getIntersection().
  • Point callers: src/manager/Window.mjs (the window under a screen point) and src/manager/DragCoordinator.mjs (twice, cross-window targeting). All three pass {bottom: y, right: x, x, y}.
  • Area caller: src/main/DomAccess.mjs#getClippedRect, guarded by fix(main): honor containing blocks in DomAccess#getClippedRect (#19984) #19997.

The Fix

  1. intersects(other) always returns the overlap Rectangle or false. A zero-size other returns false, because it has no visible overlap.
  2. Point containment gets its own method, for example containsPoint(x, y), and the three point callers move to it.
  3. Both methods get JSDoc, including their return types.

Acceptance Criteria

  • intersects() never returns true. Unit cases cover an overlapping, a disjoint, a touching and a zero-size other.
  • containsPoint() has unit cases for points inside, on the edge and outside.
  • Window.mjs and DragCoordinator.mjs use containsPoint(), and their existing unit and e2e coverage stays green.
  • No caller in src/, apps/ or examples/ still relies on a Boolean from intersects().

Out of Scope

  • Changing the semantics of includes() or contains().

Related

Live latest-open sweep: checked latest 20 open issues at 2026-10-22T13:12:53Z; no equivalent found.
Keyword sweep: gh issue list --search "Rectangle intersects" (all states): no match (only #17578, unrelated).
A2A claim sweep: last 15 lane-claims; no overlapping scope.
MC sweep: "Rectangle intersects returns boolean zero width height point": no prior decision.
Own-assignment sweep: none overlapping.

Origin Session ID: 678d216d-f4f7-41da-80d7-136e627522ff
Retrieval Hint: "Rectangle intersects mixed return Boolean zero-size point branch, getClippedRect page error"

Activity

  1. added
    enhancement
    good first issue
    core
    on Oct 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    aicoreenhancementgood first issuerefactoring

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions