Editing multi-line content in a terminal environment involves a lot of trade-offs. When LLDB's multi-line editing support was first introduced for expressions / REPL contexts the behavior was as follows:
- The Return key is treated as a line-break except at the end of the input buffer, where a completeness test is applied
This worked well enough when writing code, and makes it trivial to insert new lines above code you've already typed. Just use cursor navigation to move up and type freely. Where it was awkward is that the gesture to insert a line break and end editing is conflated for most people. Sometimes you want Return to end the editing session and other times you want to insert a line break.
This patch proposes a change in the behavior as follows:
- The Return key is treated as the end of editing except at the end of the input buffer, where a completeness test is applied
- The Meta+Return sequence is always treated as a line break. This is consistent with conventions in Facebook and elsewhere since Alt/Option+Return is often mapped to Meta+Return. The unfortunate exception is on macOS where this *can* be the case, but isn't by default. Sigh.
Note that by design both before and after the patch pasting a Return character always introduces a line break.