comparison hgext/histedit.py @ 46395:a936e570288d

histedit: notice when the main window underflows height and abort If you try to have a 13-line-tall terminal and use curses histedit, it fails by spinning in an infinite loop due to the catch-all ignore of curses errors on line 1682 of histedit.py. We should also fix that catch-all ignore of curses errors (what other demons lurk here, I wonder?) but we can trivially catch this case and guide the user to a happy path. We've seen this mostly in IDE users that have a tendency to have really tiny embedded terminal windows. Differential Revision: https://phab.mercurial-scm.org/D9854
author Augie Fackler <augie@google.com>
date Fri, 22 Jan 2021 15:32:00 -0500
parents 8477c91b5e8e
children 11ce2977572f
comparison
equal deleted inserted replaced
46394:8477c91b5e8e 46395:a936e570288d
1579 renderstring(win, state, content[start:], diffcolors=True) 1579 renderstring(win, state, content[start:], diffcolors=True)
1580 1580
1581 def layout(mode): 1581 def layout(mode):
1582 maxy, maxx = stdscr.getmaxyx() 1582 maxy, maxx = stdscr.getmaxyx()
1583 helplen = len(helplines(mode)) 1583 helplen = len(helplines(mode))
1584 mainlen = maxy - helplen - 12
1585 if mainlen < 1:
1586 raise error.Abort(
1587 _(b"terminal dimensions %d by %d too small for curses histedit")
1588 % (maxy, maxx),
1589 hint=_(
1590 b"enlarge your terminal or use --config ui.interface=text"
1591 ),
1592 )
1584 return { 1593 return {
1585 b'commit': (12, maxx), 1594 b'commit': (12, maxx),
1586 b'help': (helplen, maxx), 1595 b'help': (helplen, maxx),
1587 b'main': (maxy - helplen - 12, maxx), 1596 b'main': (mainlen, maxx),
1588 } 1597 }
1589 1598
1590 def drawvertwin(size, y, x): 1599 def drawvertwin(size, y, x):
1591 win = curses.newwin(size[0], size[1], y, x) 1600 win = curses.newwin(size[0], size[1], y, x)
1592 y += size[0] 1601 y += size[0]