# Wrong selection when using CodeMirror in ProseMirror

**URL:** <https://discuss.prosemirror.net/t/wrong-selection-when-using-codemirror-in-prosemirror/2272>\
**Category:** Uncategorized\
**Created:** [October 12, 2019, 9:06am UTC](https://discuss.prosemirror.net/t/wrong-selection-when-using-codemirror-in-prosemirror/2272 "2019-10-12T09:06:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![practice](https://discuss.prosemirror.net/letter_avatar_proxy/v4/letter/p/67e7ee/32.png) [@practice](https://discuss.prosemirror.net/u/practice)\
**Post date:** [October 12, 2019, 9:06am UTC](https://discuss.prosemirror.net/t/wrong-selection-when-using-codemirror-in-prosemirror/2272/1 "2019-10-12T09:06:13Z")

</div>

![image](https://discuss.prosemirror.net/uploads/secondsite/original/2X/4/4590f25a55745f77cff577f8bb7b45e580ab244c.png)Hi, marijn

I’m facing some problems while using CodeMirror in ProseMirror

As shown by the pic（by [Embeded CodeMirror](http://prosemirror.net/examples/codemirror/)）

Sometimes, when click outside the code\_block node, the cursor shown by the dom was right but the editor selection was pointed at the end of the code\_block content.

And the toolbar state is uncorrent.

Is there a way to fix this selection error?

---

<div class="post-metadata">

**Author:** ![marijn](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/marijn/32/15_2.png) [@marijn](https://discuss.prosemirror.net/u/marijn)\
**Post date:** [October 15, 2019, 12:14pm UTC](https://discuss.prosemirror.net/t/wrong-selection-when-using-codemirror-in-prosemirror/2272/2 "2019-10-15T12:14:23Z")

</div>

Hi. Do you have more precise instructions on how to make this occur? In which browser does it happen?

---

<div class="post-metadata">

**Author:** ![practice](https://discuss.prosemirror.net/letter_avatar_proxy/v4/letter/p/67e7ee/32.png) [@practice](https://discuss.prosemirror.net/u/practice)\
**Post date:** [October 15, 2019, 1:09pm UTC](https://discuss.prosemirror.net/t/wrong-selection-when-using-codemirror-in-prosemirror/2272/3 "2019-10-15T13:09:49Z")

</div>

thanks for your reply! the step to make this occur as the following:

1. click inside code\_block
2. click the nearest paragarph

repeat step1 and step2 when the menuItem still disabled, the editor selection is wrong. my browser is Chorme 77.0.3865.90

 ![eu1lu-udmc6](https://discuss.prosemirror.net/uploads/secondsite/original/2X/2/2779d372c97207bfe3911ff106898f055a9199e8.gif)

---

<div class="post-metadata">

**Author:** ![marijn](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/marijn/32/15_2.png) [@marijn](https://discuss.prosemirror.net/u/marijn)\
**Post date:** [October 15, 2019, 2:21pm UTC](https://discuss.prosemirror.net/t/wrong-selection-when-using-codemirror-in-prosemirror/2272/4 "2019-10-15T14:21:58Z")

</div>

I’ve been clicking for a while (also Chrome 77), but I’m not seeing this for some reason.

---

<div class="post-metadata">

**Author:** ![practice](https://discuss.prosemirror.net/letter_avatar_proxy/v4/letter/p/67e7ee/32.png) [@practice](https://discuss.prosemirror.net/u/practice)\
**Post date:** [October 20, 2019, 7:13am UTC](https://discuss.prosemirror.net/t/wrong-selection-when-using-codemirror-in-prosemirror/2272/5 "2019-10-20T07:13:03Z")

</div>

![image](https://discuss.prosemirror.net/uploads/secondsite/original/2X/0/0930b169706298c1541b03cb4b67acb8951fdbe3.jpeg)It seems that I’m running into the situation.

But the pos doesn’t equal to neither selection.from nor selection.to.

It points at the next paragraph.

why should it be equal?
