# Buggy code
def continuation_tokens(self, width, line_number, is_soft_wrap=False):
    """Displays dots in multiline prompt"""
    if is_soft_wrap:
        return ""
    width = width - 1
    dots = builtins.__xonsh__.env.get("MULTILINE_PROMPT")
    dots = dots() if callable(dots) else dots
    if dots is None:
        return [(Token, " " * (width + 1))]
    basetoks = self.format_color(dots)
    baselen = sum(len(t[1]) for t in basetoks)
    if baselen == 0:
        return [(Token, " " * (width + 1))]
    toks = basetoks * (width // baselen)
    n = width % baselen
    count = 0
    for tok in basetoks:
        slen = len(tok[1])
        newcount = slen + count
        if slen == 0:
            continue
        elif newcount <= n:
            toks.append(tok)
        else:
            toks.append((tok[0], tok[1][: n - count]))
        count = newcount
        if n <= count:
            break
    toks.append((Token, " "))  # final space
    return PygmentsTokens(toks)


# Traceback (SyntaxError)
env XONSH_DEBUG=1 xonsh --shell-type readline
~
🐮 > $XONSH_DEBUG
1
~
🐮 > $(

~
🐮 > xonsh: To log full traceback to a file set: $XONSH_TRACEBACK_LOGFILE = <filename>
Traceback (most recent call last):
File "/home/dominic/dotfiles/venvs/xonsh/.venv/lib/python3.6/site-packages/xonsh/base_shell.py", line 473, in compile
code = self.execer.compile(src, mode="single", glbs=self.ctx, locs=None)
File "/home/dominic/dotfiles/venvs/xonsh/.venv/lib/python3.6/site-packages/xonsh/execer.py", line 135, in compile
tree = self.parse(input, ctx, mode=mode, filename=filename, transform=transform)
File "/home/dominic/dotfiles/venvs/xonsh/.venv/lib/python3.6/site-packages/xonsh/execer.py", line 96, in parse
tree, input = self._parse_ctx_free(input, mode=mode, filename=filename)
File "/home/dominic/dotfiles/venvs/xonsh/.venv/lib/python3.6/site-packages/xonsh/execer.py", line 235, in _parse_ctx_free
raise original_error from None
File "/home/dominic/dotfiles/venvs/xonsh/.venv/lib/python3.6/site-packages/xonsh/execer.py", line 220, in _parse_ctx_free
debug_level=(self.debug_level > 2),
File "/home/dominic/dotfiles/venvs/xonsh/.venv/lib/python3.6/site-packages/xonsh/parsers/base.py", line 543, in parse
tree = self.parser.parse(input=s, lexer=self.lexer, debug=debug_level)
File "/home/dominic/dotfiles/venvs/xonsh/.venv/lib/python3.6/site-packages/xonsh/ply/ply/yacc.py", line 335, in parse
return self.parseopt_notrack(input, lexer, debug, tracking, tokenfunc)
File "/home/dominic/dotfiles/venvs/xonsh/.venv/lib/python3.6/site-packages/xonsh/ply/ply/yacc.py", line 1203, in parseopt_notrack
tok = call_errorfunc(self.errorfunc, errtoken, self)
File "/home/dominic/dotfiles/venvs/xonsh/.venv/lib/python3.6/site-packages/xonsh/ply/ply/yacc.py", line 194, in call_errorfunc
r = errorfunc(token)
File "/home/dominic/dotfiles/venvs/xonsh/.venv/lib/python3.6/site-packages/xonsh/parsers/base.py", line 3282, in p_error
self._parse_error("no further code", None)
File "/home/dominic/dotfiles/venvs/xonsh/.venv/lib/python3.6/site-packages/xonsh/parsers/base.py", line 676, in _parse_error
raise err
File "<string>", line None
SyntaxError: None: no further code

# Fixed code
def continuation_tokens(self, width, line_number, is_soft_wrap=False):
    """Displays dots in multiline prompt"""
    if is_soft_wrap:
        return ""
    width = width - 1
    dots = builtins.__xonsh__.env.get("MULTILINE_PROMPT")
    dots = dots() if callable(dots) else dots
    if not dots:
        return ""
    basetoks = self.format_color(dots)
    baselen = sum(len(t[1]) for t in basetoks)
    if baselen == 0:
        return [(Token, " " * (width + 1))]
    toks = basetoks * (width // baselen)
    n = width % baselen
    count = 0
    for tok in basetoks:
        slen = len(tok[1])
        newcount = slen + count
        if slen == 0:
            continue
        elif newcount <= n:
            toks.append(tok)
        else:
            toks.append((tok[0], tok[1][: n - count]))
        count = newcount
        if n <= count:
            break
    toks.append((Token, " "))  # final space
    return PygmentsTokens(toks)