<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/145715>145715</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Arrow keys to exit lldb's reverse history search inserts raw character while doing so
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            lldb
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          DavidSpickett
      </td>
    </tr>
</table>

<pre>
    OS Ubuntu 22.04.5 LTS, liedit installed from apt: 
```
libedit-dev/jammy,now 3.1-20210910-1build1 arm64 [installed]
libedit2/jammy,now 3.1-20210910-1build1 arm64 [installed,automatic]
```

I expect that searching history in lldb would work as it does in my terminal:
* `ctrl+r` enters `(reverse-i-search)`':`
* I start searching and find the command I want
* I want to edit that command before running, so I press an arrow key, usually right
* That exits the search mode and leaves the cursor one to the right of where it was

```
$
<ctrl-r>
(reverse-i-search)`': 
<nin>
(reverse-i-search)`ninj': ninja
<right arrow>
$ ninja
```
When you do this in LLDB it exits the mode but the raw character code is inserted for right arrow, instead of making the cursor move:
```
(lldb) watchpoint set variable a
bck:set
<right arrow>
(lldb) watchpoint [Cset variable a
``` 
That `[C` is actually there it's not just a visual artifact:
```
(lldb) watchpoint [Cset variable a
"[Cset" is not a valid subcommand of "watchpoint". Valid subcommands are: command, delete, disable, enable, ignore, and others. Use "help watchpoint" to find out more.
```
We know that we should exit but not that it needs to be handled as a special character.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJycVUuP4jgQ_jXmUgIlhvA45AD0IrXU0h56ZvdciSvEjWMj2yHDv1-VA0137-xDIyHi2K6v6vvqEQxBHy1RKYqdKJ4m2MfW-fIJL1q9nnV9ohgnlVPX8vdX-F71NvYg5SxbzAp4-fYq5B6MJqUjaBsiGkMKGu86wHMU8y2IbCuW2e2XbY2u-PJU0UXIwxt23VXIvXUDzGf5VGYyzzZ5Ns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