Scrolling with mouse leads to infinite exception loop
When scrolling up through the window with a mouse, reaching the end of the history results in an exception (see below).
Platform: OSX Mojave
Unhandled exception in event loop:
File "/Users/ebarr/.conda/envs/py39/lib/python3.9/site-packages/prompt_toolkit/application/application.py", line 967, in in_term
await _do_wait_for_enter("Press ENTER to continue...")
File "/Users/ebarr/.conda/envs/py39/lib/python3.9/contextlib.py", line 188, in __aexit__
await self.gen.__anext__()
File "/Users/ebarr/.conda/envs/py39/lib/python3.9/site-packages/prompt_toolkit/application/run_in_terminal.py", line 115, in in_terminal
app._redraw()
File "/Users/ebarr/.conda/envs/py39/lib/python3.9/site-packages/prompt_toolkit/application/application.py", line 556, in _redraw
self.context.copy().run(run_in_context)
File "/Users/ebarr/.conda/envs/py39/lib/python3.9/site-packages/prompt_toolkit/application/application.py", line 539, in run_in_context
self.renderer.render(self, self.layout)
File "/Users/ebarr/.conda/envs/py39/lib/python3.9/site-packages/prompt_toolkit/renderer.py", line 677, in render
layout.container.write_to_screen(
File "/Users/ebarr/.conda/envs/py39/lib/python3.9/site-packages/prompt_toolkit/layout/containers.py", line 400, in write_to_screen
c.write_to_screen(
File "/Users/ebarr/.conda/envs/py39/lib/python3.9/site-packages/prompt_toolkit/layout/containers.py", line 1753, in write_to_screen
draw_func()
File "/Users/ebarr/.conda/envs/py39/lib/python3.9/site-packages/prompt_toolkit/layout/containers.py", line 1795, in _write_to_screen_at_index
visible_line_to_row_col, rowcol_to_yx = self._copy_body(
File "/Users/ebarr/.conda/envs/py39/lib/python3.9/site-packages/prompt_toolkit/layout/containers.py", line 2121, in _copy_body
copy()
File "/Users/ebarr/.conda/envs/py39/lib/python3.9/site-packages/prompt_toolkit/layout/containers.py", line 2109, in copy
line = ui_content.get_line(lineno)
File "/Users/ebarr/.conda/envs/py39/lib/python3.9/site-packages/prompt_toolkit/layout/controls.py", line 777, in get_line
fragments = get_processed_line(i).fragments
File "/Users/ebarr/.conda/envs/py39/lib/python3.9/site-packages/prompt_toolkit/layout/controls.py", line 711, in get_processed_line
processed_line = transform(i, get_line(i))
File "/Users/ebarr/.conda/envs/py39/lib/python3.9/site-packages/prompt_toolkit/layout/controls.py", line 691, in transform
transformation = merged_processor.apply_transformation(
File "/Users/ebarr/.conda/envs/py39/lib/python3.9/site-packages/prompt_toolkit/layout/processors.py", line 1000, in apply_transformation
transformation = p.apply_transformation(
File "/Users/ebarr/Soft/katcp_cli/katcp_cli/UI.py", line 140, in apply_transformation
fragments = to_formatted_text(HTML(fragment_list_to_text(transformation_input.fragments)))
File "/Users/ebarr/.conda/envs/py39/lib/python3.9/site-packages/prompt_toolkit/formatted_text/html.py", line 33, in __init__
document = minidom.parseString(f"<html-root>{value}</html-root>")
File "/Users/ebarr/.conda/envs/py39/lib/python3.9/xml/dom/minidom.py", line 1998, in parseString
return expatbuilder.parseString(string)
File "/Users/ebarr/.conda/envs/py39/lib/python3.9/xml/dom/expatbuilder.py", line 925, in parseString
return builder.parseString(string)
File "/Users/ebarr/.conda/envs/py39/lib/python3.9/xml/dom/expatbuilder.py", line 223, in parseString
parser.Parse(string, True)
Exception not well-formed (invalid token): line 1, column 66
Press ENTER to continue...
Pressing ENTER re-raises the exception indefinitely and Ctrl-C/Z do not work to close the program.