diff --git a/babi.py b/babi.py index 720ff98..f6670a8 100644 --- a/babi.py +++ b/babi.py @@ -810,7 +810,8 @@ class File: s = match[0] if len(s) >= maxlen: s = _scrolled_line(match[0], 0, maxlen) - screen.stdscr.addstr(y, x, s, curses.A_REVERSE) + # TODO: probably should do this without `len(s)` + screen.stdscr.chgat(y, x, len(s), curses.A_REVERSE) count = 0 res: Union[str, PromptResult] = '' diff --git a/tests/replace_test.py b/tests/replace_test.py index c58864b..aa26eb3 100644 --- a/tests/replace_test.py +++ b/tests/replace_test.py @@ -162,6 +162,23 @@ def test_replace_small_window_size(ten_lines): h.press('^C') +def test_replace_height_1_highlight(): + with run() as h, and_exit(h): + h.press('x' * 90) + h.press('^\\') + h.await_text('search (to replace):') + h.press_and_enter('^x+$') + h.await_text('replace with:') + h.press('Enter') + h.await_text('replace [y(es), n(o), a(ll)]?') + + with h.resize(width=80, height=1): + h.await_text_missing('xxxxx') + h.await_text('xxxxx') + + h.press('^C') + + def test_replace_line_goes_off_screen(): with run() as h, and_exit(h): h.press(f'{"a" * 20}{"b" * 90}')