# Removing bold/italics formatting while highlighting \* results in wrong post-format-removal text highlighting

**URL:** https://meta.discourse.org/t/removing-bold-italics-formatting-while-highlighting-results-in-wrong-post-format-removal-text-highlighting/300445
**Category:** Bug
**Tags:** composer
**Created:** [March 21, 2024, 10:31pm UTC](https://meta.discourse.org/t/removing-bold-italics-formatting-while-highlighting-results-in-wrong-post-format-removal-text-highlighting/300445 "2024-03-21T22:31:27Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![seanblue](https://avatars.discourse-cdn.com/v4/letter/s/dc4da7/32.png) [@seanblue](https://meta.discourse.org/u/seanblue)
#### Post date: [March 21, 2024, 10:31pm UTC](https://meta.discourse.org/t/removing-bold-italics-formatting-while-highlighting-results-in-wrong-post-format-removal-text-highlighting/300445/1 "2024-03-21T22:31:27Z")

</div>

This one is a little weird, but I noticed it along with [Ctrl+I replaces bold formatting instead of adding additional formatting](https://meta.discourse.org/t/ctrl-i-replaces-bold-formatting-instead-of-adding-additional-formatting/300443).

Steps to reproduce:

1. Type “test” and highlight it
2. Hit Ctrl+B to get ` **test** `
3. Highlight the entire text ` **test** ` (this is admittedly a bit weird when done right after applying the bold formatting, but in a normal workflow I think it can happen more reasonably)
4. Hit Ctrl+B to remove the bold formatting

Expected: The `**` formatting is removed and the whole word `test` is highlighted  
Actual: The `**` formatting is removed, but only `st` is highlighted (which means you can’t apply additional formatting on the word without fixing the highlighting first)

![image](https://global.discourse-cdn.com/meta/original/4X/c/c/e/cceb530f60ff608c9d0882819d07f8a051112e12.png)

Note that the same happens with Ctrl+I for italics, but `est` is highlighted at the end, so it appears to be affected by how many formatting characters are removed.

---

<div class="post-metadata">

### Author: ![Firepup650](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/firepup650/32/465200_2.png) [@Firepup650](https://meta.discourse.org/u/Firepup650)
#### Post date: [March 21, 2024, 10:42pm UTC](https://meta.discourse.org/t/removing-bold-italics-formatting-while-highlighting-results-in-wrong-post-format-removal-text-highlighting/300445/2 "2024-03-21T22:42:17Z")

</div>

It seems to specifically deselect the left 2 and right two chars, for example:

```markdown
**strong**

```

Deselects the `st`. Re-bolding and then selecting all again, then de-bolding takes off the right two chars incorrectly.

```markdown
st **rong**

```

Which becomes

```plaintext
**rong

```
