This is an archive of the discontinued LLVM Phabricator instance.

[LLDB] Proposed change in multi-line edit behavior (Return = end/append, Meta+Return = line break)
ClosedPublic

Authored by k8stone on Jul 12 2016, 3:39 PM.

Details

Reviewers
zturner
clayborg
granata.enrico
labath
Group Reviewers
Restricted Project
Summary

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.

Diff Detail

Event Timeline

k8stone updated this revision to Diff 63739.Jul 12 2016, 3:39 PM
k8stone retitled this revision from to Proposed change in multi-line edit behavior (Return = end/append, Meta+Return = line break).
k8stone updated this object.
k8stone added a reviewer: Restricted Project.
k8stone added a project: Restricted Project.

This is based on a patch originally submitted by Bartosz Wróblewski here: https://llvm.org/bugs/show_bug.cgi?id=27365

Eugene.Zelenko retitled this revision from Proposed change in multi-line edit behavior (Return = end/append, Meta+Return = line break) to [LLDB] Proposed change in multi-line edit behavior (Return = end/append, Meta+Return = line break).Jul 12 2016, 6:54 PM
Eugene.Zelenko set the repository for this revision to rL LLVM.
Eugene.Zelenko added a subscriber: lldb-commits.
Eugene.Zelenko added inline comments.
include/lldb/Host/Editline.h
289

Will be good idea to not add space between name and arguments list in new code. Same for other places.

labath edited edge metadata.Jul 13 2016, 2:39 AM

looks good as far as I can tell

I second the idea of running clang-format over the patch.

clayborg requested changes to this revision.Jul 13 2016, 9:46 AM
clayborg edited edge metadata.

We should document this behavior somewhere in some help text, and run clang-format.

This revision now requires changes to proceed.Jul 13 2016, 9:46 AM
k8stone updated this revision to Diff 63867.Jul 13 2016, 3:21 PM
k8stone edited edge metadata.
k8stone removed rL LLVM as the repository for this revision.

clang-format applied. Greg's recommendation to document the multi-line editing behavior in help make sense, but should land after the major help rework in progress.

clayborg accepted this revision.Jul 13 2016, 3:36 PM
clayborg edited edge metadata.
This revision is now accepted and ready to land.Jul 13 2016, 3:36 PM

Committed in r275482.

Please mention URL of Differential revision to close it automatically after commit.

Sorry, forgot to add "[revision] in commit summary".

Fair enough! I was planning to close both out tomorrow after getting Jim to approve the other patch.