# Buggy code
def _querycompletions(self, completions, loc):
    """Returns whether or not we should show completions"""
    if os.path.commonprefix([c[loc:] for c in completions]):
        return True
    elif len(completions) <= builtins.__xonsh_env__.get("COMPLETION_QUERY_LIMIT"):
        return True
    msg = "\nDisplay all {} possibilities? ".format(len(completions))
    msg += "({GREEN}y{NO_COLOR} or {RED}n{NO_COLOR})"
    self.print_color(msg, end="", flush=True, file=sys.stderr)
    yn = "x"
    while yn not in "yn":
        yn = sys.stdin.read(1)
    show_completions = to_bool(yn)
    print()
    if not show_completions:
        rl_on_new_line()
        return False
    w, h = shutil.get_terminal_size()
    lines = columnize(completions, width=w)
    more_msg = self.format_color(
        "{YELLOW}==={NO_COLOR} more or "
        "{PURPLE}({NO_COLOR}q{PURPLE}){NO_COLOR}uit "
        "{YELLOW}==={NO_COLOR}"
    )
    while len(lines) > h - 1:
        print("".join(lines[: h - 1]), end="", flush=True, file=sys.stderr)
        lines = lines[h - 1 :]
        print(more_msg, end="", flush=True, file=sys.stderr)
        q = sys.stdin.read(1).lower()
        print(flush=True, file=sys.stderr)
        if q == "q":
            rl_on_new_line()
            return False
    print("".join(lines), end="", flush=True, file=sys.stderr)
    rl_on_new_line()
    return False


# Traceback (TypeError)
Readline internal error
Traceback (most recent call last):
File "C:\Users\mel\Anaconda3\lib\site-packages\pyreadline\console\console.py", line 768, in hook_wrapper_23
res = ensure_str(readline_hook(prompt))
File "C:\Users\mel\Anaconda3\lib\site-packages\pyreadline\rlmain.py", line 571, in readline
self._readline_from_keyboard()
File "C:\Users\mel\Anaconda3\lib\site-packages\pyreadline\rlmain.py", line 536, in _readline_from_keyboard
if self._readline_from_keyboard_poll():
File "C:\Users\mel\Anaconda3\lib\site-packages\pyreadline\rlmain.py", line 556, in _readline_from_keyboard_poll
result = self.mode.process_keyevent(event.keyinfo)
File "C:\Users\mel\Anaconda3\lib\site-packages\pyreadline\modes\emacs.py", line 243, in process_keyevent
r = self.process_keyevent_queue[-1](keyinfo)
File "C:\Users\mel\Anaconda3\lib\site-packages\pyreadline\modes\emacs.py", line 286, in _process_keyevent
r = dispatch_func(keyinfo)
File "C:\Users\mel\Anaconda3\lib\site-packages\pyreadline\modes\basemode.py", line 257, in complete
completions = self._get_completions()
File "C:\Users\mel\Anaconda3\lib\site-packages\pyreadline\modes\basemode.py", line 200, in _get_completions
r = self.completer(ensure_unicode(text), i)
File "C:\Users\mel\Anaconda3\lib\cmd.py", line 275, in complete
self.completion_matches = compfunc(text, line, begidx, endidx)
File "C:\Users\mel\Anaconda3\lib\site-packages\xonsh\__amalgam__.py", line 18735, in completedefault
show_completions = self._querycompletions(completions, endidx - begidx)
File "C:\Users\mel\Anaconda3\lib\site-packages\xonsh\__amalgam__.py", line 18695, in _querycompletions
rl_on_new_line()
TypeError: 'NoneType' object is not callable

# Fixed code
def _querycompletions(self, completions, loc):
    """Returns whether or not we should show completions"""
    if os.path.commonprefix([c[loc:] for c in completions]):
        return True
    elif len(completions) <= builtins.__xonsh_env__.get("COMPLETION_QUERY_LIMIT"):
        return True
    msg = "\nDisplay all {} possibilities? ".format(len(completions))
    msg += "({GREEN}y{NO_COLOR} or {RED}n{NO_COLOR})"
    self.print_color(msg, end="", flush=True, file=sys.stderr)
    yn = "x"
    while yn not in "yn":
        yn = sys.stdin.read(1)
    show_completions = to_bool(yn)
    print()
    if not show_completions:
        if rl_on_new_line is None:
            rl_on_new_line()
        else:
            print()
        return False
    w, h = shutil.get_terminal_size()
    lines = columnize(completions, width=w)
    more_msg = self.format_color(
        "{YELLOW}==={NO_COLOR} more or "
        "{PURPLE}({NO_COLOR}q{PURPLE}){NO_COLOR}uit "
        "{YELLOW}==={NO_COLOR}"
    )
    while len(lines) > h - 1:
        print("".join(lines[: h - 1]), end="", flush=True, file=sys.stderr)
        lines = lines[h - 1 :]
        print(more_msg, end="", flush=True, file=sys.stderr)
        q = sys.stdin.read(1).lower()
        print(flush=True, file=sys.stderr)
        if q == "q":
            rl_on_new_line()
            return False
    print("".join(lines), end="", flush=True, file=sys.stderr)
    rl_on_new_line()
    return False