diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2015-09-22 06:08:50 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2015-09-22 06:08:50 -0700 |
commit | 206f432b1b5811c99ecf5f14a914de8da37277c0 (patch) | |
tree | c14930e3690021bcf14474042b020e6b51c9067d | |
parent | d0c25e3cb12f6905a68952b0eeb9c17f6edcee48 (diff) | |
download | txr-206f432b1b5811c99ecf5f14a914de8da37277c0.tar.gz txr-206f432b1b5811c99ecf5f14a914de8da37277c0.tar.bz2 txr-206f432b1b5811c99ecf5f14a914de8da37277c0.zip |
linenoise: forward paren jump too.
* linenoise/linenoise.c (paren_jump): Scan forward also,
if reverse scan turns up nothing, thereby jumping
to a closing parenthesis in the forward direction.
* txr.1: Documentation updated.
-rw-r--r-- | linenoise/linenoise.c | 4 | ||||
-rw-r--r-- | txr.1 | 12 |
2 files changed, 14 insertions, 2 deletions
diff --git a/linenoise/linenoise.c b/linenoise/linenoise.c index 7dd29aa5..1a16ac7c 100644 --- a/linenoise/linenoise.c +++ b/linenoise/linenoise.c @@ -1118,6 +1118,9 @@ static void paren_jump(lino_t *l) { size_t pos = scan_rev(l->data, l->dpos - 1); + if (pos == -1) + pos = scan_fwd(l->data, l->dpos - 1); + if (pos != -1) { size_t dp = l->dpos; l->dpos = pos; @@ -1840,6 +1843,7 @@ static int edit(lino_t *l, const char *prompt) } break; case ')': case ']': case '}': + case '(': case '[': case '{': if (edit_insert(l,c)) { l->error = lino_ioerr; goto out; @@ -34126,12 +34126,20 @@ When any of the three closing characters or .code } is inserted, the listener scans backward for the matching opening -character. If the matching character is found, the cursor jumps to that +character. Likewise, if any of the three opening characters +.codn ( , +.codn [ +or +.code { +is inserted in the middle of text, the listener scans forward for the matching +closing character. + +If the matching character is found, the cursor jumps to that character and then returns to the original position a brief moment later. If a new character is typed during the brief time delay, the delay is immediately canceled, so as not to hinder rapid typing. -Note that the backward matching is unsophisticated; it doesn't observe the +Note that the matching is unsophisticated; it doesn't observe the lexical conventions and syntax of the \*(TL programming language. For instance, a closing parenthesis outside a string literal may match match an opening one inside a string literal. |