# Inconsistent behaviour when deleting wrapped lines

**URL:** <https://discuss.codemirror.net/t/inconsistent-behaviour-when-deleting-wrapped-lines/8119>\
**Category:** v6\
**Created:** [April 12, 2024, 3:10pm UTC](https://discuss.codemirror.net/t/inconsistent-behaviour-when-deleting-wrapped-lines/8119 "2024-04-12T15:10:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![40thieves](https://discuss.codemirror.net/user_avatar/discuss.codemirror.net/40thieves/32/588_2.png) [@40thieves](https://discuss.codemirror.net/u/40thieves)\
**Post date:** [April 12, 2024, 3:10pm UTC](https://discuss.codemirror.net/t/inconsistent-behaviour-when-deleting-wrapped-lines/8119/1 "2024-04-12T15:10:51Z")

</div>

I’ve noticed some inconsistent behaviour with the `deleteLine` command.

If the cursor is on the **last** “visual” line of a wrapped line then the cursor remains on the same line number. Note the active line number in the following screenshots before/after triggering `deleteLine`.

Before:

 ![last-visual-line-before](https://discuss.codemirror.net/uploads/default/original/2X/0/07ba96dd3853bcb5ac43c952a5a5003943646640.png)

After:

 ![last-visual-line-after](https://discuss.codemirror.net/uploads/default/original/2X/7/7867efae4ac4e97304538303755c889a3794c218.png)

* * *

If the cursor is on **any other** “visual” line then the cursor moved to the line number above. Note the active line number in the following screenshots before/after triggering `deleteLine`.

Before:

 ![other-visual-line-before](https://discuss.codemirror.net/uploads/default/original/2X/6/6d861a10b5fd592e7b499584ef4498344c62fd18.png)

After:

 ![other-visual-line-after](https://discuss.codemirror.net/uploads/default/original/2X/c/c2b86ac5683c864b1f6403f9ab92922d9a175bdb.png)

Here’s [the sandbox link](https://codemirror.net/try/?c=aW1wb3J0IHtiYXNpY1NldHVwfSBmcm9tICJjb2RlbWlycm9yIgppbXBvcnQge1ByZWN9IGZyb20gIkBjb2RlbWlycm9yL3N0YXRlIgppbXBvcnQge0VkaXRvclZpZXcsIGtleW1hcH0gZnJvbSAiQGNvZGVtaXJyb3IvdmlldyIKaW1wb3J0IHtkZWxldGVMaW5lfSBmcm9tICJAY29kZW1pcnJvci9jb21tYW5kcyIKCm5ldyBFZGl0b3JWaWV3KHsKICBkb2M6ICJcblxuaGVsbG8gd29ybGQgaGVsbG8gd29ybGQgaGVsbG8gd29ybGQgaGVsbG8gd29ybGQgaGVsbG8gd29ybGQgaGVsbG8gd29ybGQgaGVsbG8gd29ybGQgaGVsbG8gd29ybGQgaGVsbG8gd29ybGQgaGVsbG8gd29ybGQgaGVsbG8gd29ybGQgaGVsbG8gd29ybGQgaGVsbG8gd29ybGQgaGVsbG8gd29ybGQgaGVsbG8gd29ybGQgaGVsbG8gd29ybGQgaGVsbG8gd29ybGQgaGVsbG8gd29ybGQgaGVsbG8gd29ybGRcblxuIiwKICBleHRlbnNpb25zOiBbCiAgICBiYXNpY1NldHVwLAogICAgRWRpdG9yVmlldy5saW5lV3JhcHBpbmcsCiAgICBQcmVjLmhpZ2goCiAgICAgIGtleW1hcC5vZihbewogICAgICAgIGtleTogJ01vZC1kJywKICAgICAgICBwcmV2ZW50RGVmYXVsdDogdHJ1ZSwKICAgICAgICBydW46IGRlbGV0ZUxpbmUsCiAgICAgIH1dKQogICAgKQogIF0sCiAgcGFyZW50OiBkb2N1bWVudC5ib2R5Cn0pCg==) where I reproduced in Chrome, Firefox and Safari.

I wasn’t sure if this was an intentional behavioural choice or a bug? If it’s the latter then I’d be happy to move to the issue tracker.

---

<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:** [April 12, 2024, 4:55pm UTC](https://discuss.codemirror.net/t/inconsistent-behaviour-when-deleting-wrapped-lines/8119/2 "2024-04-12T16:55:05Z")

</div>

This patch should help.

> <https://github.com/codemirror/commands/commit/19491af5ddb8909442e078566c9b69f95885fcb8>
>
> FIX: Fix an issue where \`deleteLine\` sometimes leaves the cursor on the wrong li…ne.
> 
> See https://discuss.codemirror.net/t/inconsistent-behaviour-when-deleting-wrapped-lines/8119
