Fix highlighting replacement on 1-tall screen

This commit is contained in:
Anthony Sottile
2020-01-02 18:51:31 -08:00
parent 6e1ad7eff6
commit 2bcb8f0ed0
2 changed files with 19 additions and 1 deletions

View File

@@ -810,7 +810,8 @@ class File:
s = match[0] s = match[0]
if len(s) >= maxlen: if len(s) >= maxlen:
s = _scrolled_line(match[0], 0, 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 count = 0
res: Union[str, PromptResult] = '' res: Union[str, PromptResult] = ''

View File

@@ -162,6 +162,23 @@ def test_replace_small_window_size(ten_lines):
h.press('^C') 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(): def test_replace_line_goes_off_screen():
with run() as h, and_exit(h): with run() as h, and_exit(h):
h.press(f'{"a" * 20}{"b" * 90}') h.press(f'{"a" * 20}{"b" * 90}')