Commit graph

25 commits

Author SHA1 Message Date
Martin Kühl
73ea36569e plumb/basic: avoid wrap around in file:1:2 (#158)
Fixes #122, #140.

As reported in #122, `file:1:1` moves to the end of the file,
and `file:1:2` fails with “address out of range”.

I’ll use file:2:3 as an example so we can tell the line and column number apart.

What’s happening is this:
plumb/basic matches `2:3` using twocolonaddr (from plumb/fileaddr),
then sets addr to `2-#1+#3`
(the 1 is constant and was introduced because column numbers are 1-based).
Acme interprets this in three steps:

1. find the range (q0, q1) that contains line 2
2. create the range (q2, q2) where q2 = q0 - 1
3. create the range (q3, q3) where q3 = q2 + 3

The second step has a branch where if q0 == 0 and 1 > 0
(remember that 1 is constant and comes form plumb/basic),
q0 is set to the end of the file.
This makes addressing things at the end of the file easier.

The problem then is that if we select line 1,
which starts at the beginning of the file,
q0 is always 0 and the branch in step 2) will always be used.
`1:1` is interpreted as `1-#1+#1` which starts at 0, wraps around to the end of the file, then moves 1 character backwards and then forwards again, ending at the end of the file.
`1:2` is interpretes as `1-#1+#2` which starts at 0, wraps around to the end od the file, then moves 1 character backwards and tries moving 2 characters forwards beyond the end of the file, resulting in the out of range error.

In #140 @rsc proposed transforming `:X:Y` into `:X-#0+#Y-#1` instead since that
avoids wrapping around by not moving backwards at first.
This change modifies `plumb/basic` to do that.
2018-11-13 23:59:04 -05:00
Russ Cox
82abcd6fd6 plumb: allow @ in file names
Helps Go module download cache, Upspin, maybe others.
2018-11-12 11:09:39 -05:00
Rob Pike
5a69e405fc acme: scroll a directory window when navigating if:
- the cursor is on the last line
        - the navigation would put the cursor over the tag of the following text

R=rsc
CC=smckean83
https://codereview.appspot.com/15280045
2013-10-22 16:47:48 -07:00
Russ Cox
f0a4e8bd6c plumb: character offsets start at 1, not 0
x:10:1 is the beginning of line 10

R=rsc
http://codereview.appspot.com/4960049
2011-08-31 09:22:22 -04:00
Russ Cox
c84e737c3f plumb: column numbers in file address
R=rsc
http://codereview.appspot.com/2776042
2010-10-27 17:31:18 -07:00
Russ Cox
9a0e004842 plumb: change inferno module path to /usr/inferno/module (Anthony Sorace) 2009-05-17 10:54:56 -07:00
Russ Cox
64851eee5f plumbing: move email rule below file rules (Bengt Kleberg) 2008-04-17 07:56:34 -04:00
rsc
41deef57ef plumb all urls, not just images (TheWhiteTiger) 2007-04-03 12:49:27 +00:00
rsc
e50b313e64 allow _ - / in header file names 2006-07-05 17:12:57 +00:00
rsc
8b0728d3b5 use 9 page instead of page 2006-06-06 13:58:19 +00:00
rsc
4de03b544c add $plan9 variable 2005-01-11 19:46:06 +00:00
rsc
f69a6ff541 call wmail to send mail. 2004-08-22 15:38:10 +00:00
rsc
dee84543e1 plumbing foo.html now sends it to the editor --
this is more in keeping with plan 9 behavior.

plumbing file:foo.html adds the appropriate
full path and sends it to the web browser.
2004-08-11 02:16:07 +00:00
rsc
263388c0bb use psv 2004-06-10 19:52:59 +00:00
rsc
3040f28913 plumb urls and html to web browsers 2004-06-09 14:07:16 +00:00
rsc
f1bfc54e12 More little bug fixes 2004-05-14 17:45:39 +00:00
rsc
661756d715 small fixes 2004-04-21 23:34:32 +00:00
rsc
6b53e2a4d0 push man pages through nobs. 2004-04-19 05:53:47 +00:00
rsc
4cdbf87a15 Remove a debugging print, more cleanup. 2004-03-02 23:16:37 +00:00
rsc
af78a4cd2b Little tweaks and documentation. 2004-03-02 23:11:58 +00:00
rsc
32f69c36e0 Add support for user-level 9P servers/clients and various bug fixes to go with them. 2003-12-11 17:48:38 +00:00
rsc
ccee548fda . 2003-12-04 19:18:06 +00:00
rsc
e89321a56e B that knows about address syntax,
change plumber to use it.
2003-12-02 21:57:32 +00:00
rsc
e39b8b1928 More X11 snarf tweaks.
Will we ever finish?
2003-12-02 03:42:46 +00:00
rsc
e70f305083 add plumbing files. 2003-11-23 18:30:04 +00:00