Open Bug 1490667 Opened 7 years ago Updated 3 years ago

Goal column for vertical cursor motion gets confused by programmatic selection changes

Categories

(Core :: DOM: Editor, defect, P3)

defect

Tracking

()

Tracking Status
firefox62 --- affected
firefox63 --- affected
firefox64 --- affected

People

(Reporter: marijnh, Unassigned)

Details

Attachments

(2 files)

Attached file goalcol.html
I'm not sure if goal column is the term used internally in Gecko, but I mean the feature where vertically moving the cursor across short lines will, after you get back on a long line, put you back at/near your original horizontal offset. This requires some hidden state, and it seems maintaining that hidden state goes wrong when the selection is set from JavaScript—subsequent arrow up/down motions go back to an old horizontal position, and seem to ignore the position of the programmatically set selection. The attached HTML file contains detailed reproduction instructions. But the basic thing you have to do is move vertically (arrow up/down), then set the selection from JavaScript, and then move vertically again. The horizontal offset will correspond to the last vertical motion done directly by the user. Other browsers do not behave this way, and it seems like using the _current_ selection position is more likely to be what people expect to be used here.
Oh, plot twist, it seems that this only happens when `Selection.addRange` is used, not `Selection.collapse`, and I uploaded the wrong version of the reproduction example file. Use the second attached file to actually see the issue.
Relatedly, calling `getSelection().modify("move", "forward", "line")` multiple times in a row does not result in goal-column-aware motion, since apparently there the goal _is_ reset (incorrectly—it should be preserved during line motion) on every update.
Hi Marijn, I've tested and I can reproduce your issue on the latest builds from Nightly 64(20180916220033), Beta 63(20180913141435) and Release 62(20180830143136) channels. Environments covered: MacOs 10.12, Win10 x64, Win7 x64 Thanks for reporting!
Component: Untriaged → Document Navigation
Product: Firefox → Core
Component: Document Navigation → Editor
caret behaviour is layout/generic/nsFrameSelection.cpp that isn't editor.... But it keeps editor component for this bug....
Priority: -- → P3
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: