Skip to content

Commit

Permalink
fix completion UI breaking on window change
Browse files Browse the repository at this point in the history
Related to #1067.  This commit fixes a problem with the width not being
updated in the completion UI as a side effect of ignoring SIGWINCH.
  • Loading branch information
lukaswrz committed Jan 22, 2022
1 parent 3ab4e69 commit 3e4c8dd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
6 changes: 5 additions & 1 deletion core/main_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"""
from __future__ import print_function

import sys
import sys, signal

from _devbuild.gen.syntax_asdl import (
command_t, command, parse_result__Node, parse_result_e
Expand Down Expand Up @@ -203,6 +203,8 @@ def Interactive(flag, cmd_ev, c_parser, display, prompt_plugin, errfmt):
# - display.EraseLines() needs to be called BEFORE displaying anything, so
# it appears in all branches.

signal.signal(signal.SIGWINCH, lambda x, y: display.OnWindowChange())

while True: # ONLY EXECUTES ONCE
prompt_plugin.Run()
try:
Expand Down Expand Up @@ -248,6 +250,8 @@ def Interactive(flag, cmd_ev, c_parser, display, prompt_plugin, errfmt):

display.EraseLines() # Clear candidates right before executing

signal.signal(signal.SIGWINCH, signal.SIG_IGN)

# to debug the slightly different interactive prasing
if cmd_ev.exec_opts.noexec():
ui.PrintAst(node, flag)
Expand Down
7 changes: 0 additions & 7 deletions core/pyos.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,13 +280,6 @@ def InitInteractiveShell(self, display):
# This prevents Ctrl-Z from suspending OSH in interactive mode.
signal.signal(signal.SIGTSTP, signal.SIG_IGN)

# Register a callback to receive terminal width changes.
# NOTE: In line_input.c, we turned off rl_catch_sigwinch.
#signal.signal(signal.SIGWINCH, lambda x, y: display.OnWindowChange())

# Disabled because it causes wait builtin to abort (issue 1067)
signal.signal(signal.SIGWINCH, signal.SIG_IGN)

def AddUserTrap(self, sig_num, handler):
# type: (int, Any) -> None
"""For user-defined handlers registered with the 'trap' builtin."""
Expand Down

0 comments on commit 3e4c8dd

Please sign in to comment.