Minimal reproduction for a bug where EditorSelection.cursor(pos, assoc) does not respect the assoc parameter when the selection is provided to EditorState.create().
When creating an initial selection at a line-wrap boundary with assoc=-1, the cursor should appear at the end of the first visual line. Instead, it appears at the start of the second visual line (as if assoc=1).
// Position 48 is at the wrap boundary (at 400px container width)
// assoc=-1 should place cursor at END of first visual line
const selection = EditorSelection.create([EditorSelection.cursor(48, -1)]);
const state = EditorState.create({
doc: text,
extensions: [EditorView.lineWrapping],
selection, // <-- assoc is ignored here
});Cursor appears at the end of the first visual line (right edge).
Cursor appears at the start of the second visual line (left edge).
pnpm install
pnpm devOpen http://localhost:5173 and observe the cursor position.
@codemirror/state: 6.5.2@codemirror/view: 6.39.8