vim-python-pep8-indent icon indicating copy to clipboard operation
vim-python-pep8-indent copied to clipboard

Indentation Bug: constant dictionary

Open Wsine opened this issue 3 years ago • 1 comments

A minimal example is as below. every step I only type o to trigger to indentation.

Animation

import logging

# from: https://stackoverflow.com/a/56944256
class CustomFormatter(logging.Formatter):
    GREY = "\x1b[38;20m"
    YELLOW = "\x1b[33;20m"
    BLUE = "\x1b[34;20m"
    RED = "\x1b[31;20m"
    BOLD_RED = "\x1b[31;1m"
    RESET = "\x1b[0m"
    CONTENT = "%(levelname)s - %(message)s (%(filename)s:%(lineno)d)"

    FORMATS = {
        logging.DEBUG: BLUE + CONTENT + RESET,
        logging.INFO: GREY + CONTENT + RESET,
        logging.WARNING: YELLOW + CONTENT + RESET,
        logging.ERROR: RED + CONTENT + RESET,
        logging.CRITICAL: BOLD_RED + CONTENT + RESET
    }

    def format(self, record):
        log_fmt = self.FORMATS.get(record.levelno)
        formatter = logging.Formatter(log_fmt)
        return formatter.format(record)

Wsine avatar Jul 12 '22 05:07 Wsine

"\x1b[38;20m" line is enough actually to recreate this issue. I think there is a problem with parsing brackets inside of strings (regardless of escape chars). Another issue that I have is with curly brackets:

var = 0
f'{var} {{'

Or even this

asd = '{'

This will also create the same issue and it's really annoying.

vilari-mickopf avatar Aug 09 '22 13:08 vilari-mickopf