BUG selection.ranges returns wrong data

I have a need to reset the copy, cut, and paste shortcuts, so the solution is that I use keymap to override the default shortcuts.
Then when I got the content selected by the user’s cursor, I found that when state.selection.ranges returns, from and to are always 0, which is inconsistent with the actual selection of the user. At the same time, I use changeByRange to manually set and then execute state.selection.ranges to return incorrectly.
This seems to be a bug

@codemirror/state”: “^6.2.1”,
@codemirror/view”: “6.13.2”,

You’re going to have to show what you are actually doing for me to look at this. Maybe you’re reading an old state?

Haha Yes, I later found out that the state I used was an instance of EditorState.create. There is something wrong with this state. I can replace it with the state in the EditorView instance.


const state = EditorState.create()


const view = new EditorView()

Thank you for your reply