# Selection problems

**URL:** <https://discuss.codemirror.net/t/selection-problems/9830>\
**Category:** v6\
**Created:** [July 21, 2026, 6:01pm UTC](https://discuss.codemirror.net/t/selection-problems/9830 "2026-07-21T18:01:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![feraxhp](https://discuss.codemirror.net/user_avatar/discuss.codemirror.net/feraxhp/32/4963_2.png) [@feraxhp](https://discuss.codemirror.net/u/feraxhp)\
**Post date:** [July 21, 2026, 6:01pm UTC](https://discuss.codemirror.net/t/selection-problems/9830/1 "2026-07-21T18:01:41Z")

</div>

Hi, @marijn , sorry, again me, asking for the selection problems, i have a problem again, with a widget, i have 2 consecutive widgets one with a `<br>` and the other with a simple span with text, is there any way of avoiding this selection error with those 2 widgets consecutive?

[codemirror try](https://codemirror.net/try/#c=aW1wb3J0IHsgYmFzaWNTZXR1cCwgRWRpdG9yVmlldyB9IGZyb20gImNvZGVtaXJyb3IiCmltcG9ydCB7IExpbmUsIFN0YXRlRWZmZWN0LCBTdGF0ZUZpZWxkLCBSYW5nZSwgVHJhbnNhY3Rpb24sIEVkaXRvclN0YXRlIH0gZnJvbSAiQGNvZGVtaXJyb3Ivc3RhdGUiOwppbXBvcnQgeyBEZWNvcmF0aW9uLCBWaWV3UGx1Z2luLCBWaWV3VXBkYXRlLCBXaWRnZXRUeXBlIH0gZnJvbSAiQGNvZGVtaXJyb3IvdmlldyI7CgpjbGFzcyBCcmVha1dpZGdldCBleHRlbmRzIFdpZGdldFR5cGUgewogIHRvRE9NKCkgeyByZXR1cm4gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgiYnIiKSB9CiAgZ2V0IGxpbmVCcmVha3MoKSB7IHJldHVybiAxIH0KfQpjb25zdCB3aWRnZXQgPSBuZXcgQnJlYWtXaWRnZXQoKTsKCmNsYXNzIFNwYWNlciBleHRlbmRzIFdpZGdldFR5cGUgewogIGNvbnN0cnVjdG9yKHRleHQpIHsgCiAgICBzdXBlcigpCiAgICB0aGl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5kZWNvcmF0aW9ucy5mcm9tKGZpZWxkLCB2YWx1ZSA9PiB2YWx1ZS5kZWNvcmF0aW9ucykKfSkKCm5ldyBFZGl0b3JWaWV3KHsKICBkb2M6ICJxdWl0ZSBqdWdlIGFtb3VudCBvZiB0ZXh0IHF1aXRlIGp1Z2UgYW1vdW50IG9mIHRleHQgcXVpdGUganVnZSBhbW91bnQgb2YgdGV4dCBxdWl0ZSBqdWdlIGFtb3VudCBvZiB0ZXh0ICIsCiAgZXh0ZW5zaW9uczogWwogICAgYmFzaWNTZXR1cCwKICAgIHN0YXRlX2ZpZWxkCiAgXSwgIAogIHBhcmVudDogZG9jdW1lbnQuYm9keQp9KQo=)

---

<div class="post-metadata">

**Author:** ![feraxhp](https://discuss.codemirror.net/user_avatar/discuss.codemirror.net/feraxhp/32/4963_2.png) [@feraxhp](https://discuss.codemirror.net/u/feraxhp)\
**Post date:** [July 21, 2026, 8:51pm UTC](https://discuss.codemirror.net/t/selection-problems/9830/2 "2026-07-21T20:51:26Z")

</div>

For some reason putting a side of 10 fixes the issue. but the cursor still moving horrible, it shows in the wrong position.

---

<div class="post-metadata">

**Author:** ![marijn](https://discuss.codemirror.net/user_avatar/discuss.codemirror.net/marijn/32/136_2.png) [@marijn](https://discuss.codemirror.net/u/marijn)\
**Post date:** [July 24, 2026, 8:54am UTC](https://discuss.codemirror.net/t/selection-problems/9830/3 "2026-07-24T08:54:17Z")

</div>

The patch below should help with the drawing of the selection. You never really described _what_ the problem was, and the thing I saw and fixed has nothing to do with cursor selections, so maybe you’re talking about something else. If so, it’d help if you’d describe the issue.

> **[Restore support for widget-skipping coordsAtPos queries · 4919130f41](https://code.haverbeke.berlin/codemirror/view/commit/4919130f41efb45600349f4bc88a804ae6301d9f)**
>
> FIX: Fix incorrectly drawn selection when a line wrap point lies between widgets.
> 
> See https://discuss.codemirror.net/t/selection-problems/9830
