From 3d6e5cb56a6249e7f3001091fe81c171cd501319 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Thu, 2 Nov 2017 11:58:07 -0400 Subject: acme: preserve window position and selection during Get Before, executing Get in a file rewound the window offset and selection to the start of the file. After this CL, Get preserves the window offset and selection, where preserve is defined as "the same line number and rune offset within the line". So if the window started at line 10 before and the selection was line 13 chars 5-7, then that will still be true after Get, provided the new content is large enough. This should help the common situation of plumbing a compiler error, realizing the window is out of date, clicking Get, and then losing the positioning from the plumb operation. --- src/cmd/acme/text.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/cmd/acme/text.c') diff --git a/src/cmd/acme/text.c b/src/cmd/acme/text.c index 4832de8e..8ff5884d 100644 --- a/src/cmd/acme/text.c +++ b/src/cmd/acme/text.c @@ -1615,7 +1615,7 @@ textsetorigin(Text *t, uint org, int exact) Rune *r; uint n; - if(org>0 && !exact){ + if(org>0 && !exact && textreadc(t, org-1) != '\n'){ /* org is an estimate of the char posn; find a newline */ /* don't try harder than 256 chars */ for(i=0; i<256 && orgfile->b.nc; i++){ -- cgit v1.2.3