Vimjas / vim-python-pep8-indent

A nicer Python indentation style for vim.
Creative Commons Zero v1.0 Universal
786 stars 69 forks source link

Python indentation broken after b'{' #140

Open ghost opened 3 years ago

ghost commented 3 years ago

A byte string like b'{ with no } breaks python-indent, resulting in the following indentation:

def parse_license(license):
    if license.startswith(b'{'):
                             print('json license')
                             else:
                             print('regular license')

This does not happen with a regular string ('{') or a raw string (r'{').

ghost commented 3 years ago

Seems like it's actually caused by another plugin (see vim-python/python-syntax#75). vim-python-pep8-indent alone does not trigger the bug, but the two together make it even worse than just python-syntax alone.

prayatharth commented 3 years ago

can i try to fix this ? i am a beginner but will try my best. :)

blueyed commented 3 years ago

@prayatharth Sure! Although you should know your way around (debugging) Vimscript already I guess.

As for the issue: there is some special handling of syntax attributes already (https://github.com/blueyed/vim-python-pep8-indent/blob/978a5ccd61a69751a7893d01f41561897127d9dc/indent/python.vim#L72) - likely it does not catch the one from python-syntax or something like that.