Patchwork D9854: histedit: notice when the main window underflows height and abort

login
register
mail settings
Submitter phabricator
Date Jan. 22, 2021, 8:46 p.m.
Message ID <differential-rev-PHID-DREV-ihozhc4djp2pzsbutejg-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/48165/
State Superseded
Headers show

Comments

phabricator - Jan. 22, 2021, 8:46 p.m.
durin42 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D9854

AFFECTED FILES
  hgext/histedit.py

CHANGE DETAILS




To: durin42, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -1581,10 +1581,19 @@ 
     def layout(mode):
         maxy, maxx = stdscr.getmaxyx()
         helplen = len(helplines(mode))
+        mainlen = maxy - helplen - 12
+        if mainlen < 1:
+            raise error.Abort(
+                _(b"terminal dimensions %d by %d too small for curses histedit")
+                % (maxy, maxx),
+                hint=_(
+                    b"enlarge your terminal or use --config ui.interface=text"
+                ),
+            )
         return {
             b'commit': (12, maxx),
             b'help': (helplen, maxx),
-            b'main': (maxy - helplen - 12, maxx),
+            b'main': (mainlen, maxx),
         }
 
     def drawvertwin(size, y, x):