From: NeilBrown Date: Fri, 8 Sep 2023 06:20:08 +0000 (+1000) Subject: render-lines: handle case where cursor at end-of-file. X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=99f22547f46ea99d43a9669dcb2bc86d7b38e888;p=edlib.git render-lines: handle case where cursor at end-of-file. When cursor is at end-of-file, revalidate_start() wasn't detecting that it was on-screen. Signed-off-by: NeilBrown --- diff --git a/DOC/TODO.md b/DOC/TODO.md index 0b515397..f9a17946 100644 --- a/DOC/TODO.md +++ b/DOC/TODO.md @@ -10,7 +10,7 @@ the file. ### Triage - [X] find-document - if default doc has <>, displays wrongly. -- [ ] From start-of-file move to end, then up, then down. +- [X] From start-of-file move to end, then up, then down. Display jumps. Why? - [ ] Add menubar menu with recent documents? - [ ] why does clicking on status line go to top-of-file? diff --git a/render-lines.c b/render-lines.c index 4283ce28..ac8461f6 100644 --- a/render-lines.c +++ b/render-lines.c @@ -1043,7 +1043,7 @@ static int revalidate_start(struct rl_data *rl safe, int shifts = 0; /* This loop is fragile and sometimes spins. So ensure we - * never loop more than 1000 times. + * never loop more than 100 times. */ if (pm && !rl->do_wrap && !rl->shift_locked && shifts++ < 100) { int prefix_len; @@ -1133,6 +1133,9 @@ static int revalidate_start(struct rl_data *rl safe, /* Cursor is on this line */ offset = call_render_line_to_point(focus, pm, m); + if (pm && mark_same(m, pm)) + /* Probably EOF - cursor is here */ + offset = 0; found = measure_line(p, focus, m, offset); hp = m->mdata; diff --git a/tests.d/00-basic b/tests.d/00-basic index 2c0e1091..bf1ff973 100644 --- a/tests.d/00-basic +++ b/tests.d/00-basic @@ -20,13 +20,13 @@ Display 80,30 16F0ED4E9D82A43F6F5EDA022FF7A82B 1,25 Key ":Enter" Display 80,30 E28619A04BD7CF7C2762B6F9B3243BC0 1,26 Key ":Backspace" -Display 80,30 354558B32D3AEA5F529176CC1126F9C3 1,26 +Display 80,30 D9E82472B45D238257CBEEB594705081 1,25 Key ":C-_" Display 80,30 E28619A04BD7CF7C2762B6F9B3243BC0 1,26 Key ":C-_" -Display 80,30 EA06C1F166151658C2742E4860D83580 1,26 +Display 80,30 16F0ED4E9D82A43F6F5EDA022FF7A82B 1,25 Key ":C-X" -Display 80,30 AE83375F702EEAFB20AEC86E9C393B69 1,26 +Display 80,30 715E233203438550E2B970240D7A6186 1,25 Key ":C-V" Display 80,30 B116277653C29D730B60D8C76FE09D5A 1,0 Key ":C-N" @@ -728,4 +728,4 @@ Key ":C-X" Display 80,30 6C71927B10030D3ABC828BF38CF37799 1,3 Key ":C-C" Display 80,30 39B814F1E8577AAD3DF0FAE0D5E0B412 21,8 -Close 1967 +Close 1965 diff --git a/tests.d/01-redraw b/tests.d/01-redraw index 27bd63bd..8061d47d 100644 --- a/tests.d/01-redraw +++ b/tests.d/01-redraw @@ -18,11 +18,11 @@ Display 80,30 B116277653C29D730B60D8C76FE09D5A 1,0 Key ":A->" Display 80,30 16F0ED4E9D82A43F6F5EDA022FF7A82B 1,25 Key ":Backspace" -Display 80,30 FD52E23B6971746A077359B0C4CB4508 1,26 +Display 80,30 FD8E2391DFCB5171F43CBDFF94EE9881 1,24 Key ":Backspace" -Display 80,30 20A221AC28EA2038334BB938C7ECBE34 1,26 +Display 80,30 6F4DCF6C2377FEAD0FEDB441064B3965 1,23 Key ":Backspace" -Display 80,30 FF3F74E5CACAEE6053D5E97FE04748C0 58,25 +Display 80,30 B6540472F58AB1F783CC19026ED8042C 58,22 Key ":C-L" Display 80,30 FF3F74E5CACAEE6053D5E97FE04748C0 58,25 Key ":C-L" @@ -30,15 +30,15 @@ Display 80,30 47A9F237651C2589DA61322539C15C08 58,0 Key ":A->" Display 80,30 93B475250CC615423C901070387A2E75 58,0 Key ":Enter" -Display 80,30 20A221AC28EA2038334BB938C7ECBE34 1,26 +Display 80,30 CA8CAEE504414B7D1F8B8C551B81030E 1,1 Key ":C-U" -Display 80,30 2163A0D46C0DC955DAECA5C731097088 1,26 +Display 80,30 0FECC1058FFD056D9BACBCC5B317281A 1,1 Key ":C-X" -Display 80,30 A3990F4AB31ED410CECCFF2D8D31E623 1,26 +Display 80,30 2F49E1FB67BC2A2DDC2CA32459BB574B 1,1 Key "-k" Display 80,30 41AC9C3CD03D07B52B6A3DA48C7AB730 1,8 Key ":C-X" Display 80,30 D9F43AF47815B46A3E90E0795A30B979 1,8 Key ":C-C" Display 80,30 41AC9C3CD03D07B52B6A3DA48C7AB730 1,8 -Close 210 +Close 185 diff --git a/tests.d/02-grep b/tests.d/02-grep index 05323063..301a999d 100644 --- a/tests.d/02-grep +++ b/tests.d/02-grep @@ -71,7 +71,7 @@ Display 80,30 195C2466FF42AB63B832030E4B44D3F4 1,1 Key ":C-X" Display 80,30 6480624A6FD9BE7C74F17BA5F093F3AD 1,1 Key "-`" -Display 80,30 C95517897FA2FDD36E0D32F2ADE24A99 1,7 +Display 80,30 0BC8B8BCE02BFFDADAFCC520BA81A133 1,7 Display 80,30 0BC8B8BCE02BFFDADAFCC520BA81A133 1,7 Key "-`" Display 80,30 A493DDF40FA2085D4FC2CB2A8D3190E1 1,6 @@ -242,4 +242,4 @@ Key ":C-X" Display 80,30 1B93FE4A0F3F6D0DA9A9A7767239F356 1,6 Key ":C-C" Display 80,30 B37B7E24D9F5A46FEB16A84E6714994B 1,6 -Close 905 +Close 904 diff --git a/tests.d/02-spell b/tests.d/02-spell index 9954ea56..e7fa8ea9 100644 --- a/tests.d/02-spell +++ b/tests.d/02-spell @@ -170,13 +170,13 @@ Display 80,30 646155914C98AE5D6BFA41C8B18D856A 26,12 Display 80,30 ADD299094EC0777DC19C689F6AAA04AD 26,12 Key ":A->" Display 80,30 DCB4EE9C14AF1786DBA070A66CAD4A14 1,25 -Display 80,30 38130B9D67A5E7F3D06F8BEBA2B96AAF 1,26 +Display 80,30 D4011738417E9401FED57C1EC35AC20D 1,25 Key ":A-3" -Display 80,30 D404E447DED8F584462321714C25B13F 1,26 +Display 80,30 EF8285B322B339D150BB6DC5767C66C1 1,25 Key ":A-0" -Display 80,30 36B0C9F47F36CB22ADB10DE9C476680A 1,26 +Display 80,30 CDE165DBC562CB923BFA71596594207A 1,25 Key ":A-0" -Display 80,30 A12F3E091B7703E4D117C5A11A88B92F 1,26 +Display 80,30 515187C871B41285E2F176A911EE5E6B 1,25 Key ":C-P" Display 80,30 F79ADB89E71133C88676BE8BB0106221 1,0 Display 80,30 E90FBCC73FFFB16FDE18F68C446A34B5 1,0 @@ -232,4 +232,4 @@ Key ":C-X" Display 80,30 058EA2C9F282A5E7BA69102EE55E04DF 20,21 Key ":C-C" Display 80,30 BD48CEE0571DEC5245F33C1CB4681B64 20,21 -Close 624 +Close 623