In src/cursed/multiview.lua, the mouse_forward function in the keymap computes rel_y from Multiview.child_at() and then sets the forwarded mouse event's y to rel_y (the y relative to the child's body start). However, SpanManager:screen_to_file() in src/cursed/span_manager.lua does not subtract the view's _viewport_y from the passed sy before calling View:viewport_line_at_row(). The child's _viewport_y is set to the body y offset during rendering, so the forwarded rel_y is misinterpreted as an absolute screen y, causing incorrect line/col resolution.
Moreover, the conversion of start_y for drag events (me.start_y - (me.y - rel_y)) is also based on the same erroneous rel_y and will be off by the header height and child offset.
Impact: Mouse clicks in multiview children (clicking to focus, drag to select, wheel scrolling) may land on the wrong buffer position or on lines above/below the intended target.
Root cause: SpanManager:screen_to_file() should subtract view._viewport_y from sy before passing to viewport_line_at_row(). Additionally, the mouse event forwarded should retain the original absolute screen x/y and let the child's own span_manager handle the offset via the already-set _viewport_y during its render cycle.
Recommended fix:
- In
SpanManager:screen_to_file(), adjustsyby subtractingview._viewport_ybefore callingview:viewport_line_at_row(). - In
Multiview's mouse forwarding, pass the originalme.xandme.yunchanged, and only convertstart_x/start_yby addingme - (child_abs_y - me.y)(or similar).
Commit range: 335f21a5
Related commits: 335f21a5