Skip to content

Indentation broken after b'{'  #75

Description

I ran a git bisect and it seems like since commit 8d58bf4 back in 2016 this plugin breaks indentation after a byte string with an unclosed {, such as b'{', resulting in the following indentation:

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

I have no idea how a syntax highlighting plugin breaks this, but it does.

Reproduced on Debian 10 x64 and NVIM v0.5.0-799-g186ba3b68 with minimal init.vim:

call plug#begin('~/.config/nvim/plugged')
Plug 'vim-python/python-syntax'
call plug#end()

Activity

nfnty commented on Dec 2, 2020

@nfnty
Member

I have currently no clue why this occurs, but the issue disappears when you remove all the contains= from pythonBytes at L171-L174. Seems to also still work if you only keep contains=@Spell.

martician1 commented on Jul 14, 2024

@martician1

Same problem here with b'[',
without python-syntax:

s = b'check indent ['
# <---------------------- when i press enter my cursor ends up here.

with python-syntax:

s = b'check indent ['
                    # <---------------------- when i press enter my cursor ends up here.

dmitmel commented on Jun 24, 2026

@dmitmel

This bug can be fixed by renaming the groups python(Raw)Bytes to python(Raw)ByteString (or something else that ends with String). It exists because of this check: https://github.com/vim/vim/blob/cf85d97bafdcc7837a77ab79cc04da189fa3dd0c/runtime/autoload/python.vim#L64.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions