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

Indention not working after using escaped {

Open clouddistortion opened this issue 4 years ago • 12 comments

Hi, I am escaping a curly bracket in a string and after that line of code the indention breaks and runs mad. id=1 d="somestring" LINEBREAK="\n" rendered_result = 'System_Boundary({id},"{descr}") {{'.format(id=id,descr=d) + LINE_BREAK

The following line indention is 62 characters long

clouddistortion avatar Feb 07 '20 19:02 clouddistortion

Please provide a full example that (does not) work(s) by itself. The above is not valid Python code, and the next line's indent is 1 as expected.. ;)

blueyed avatar Feb 07 '20 20:02 blueyed

For sure :)

Here a working example code.

def some_function():
    id=1
    d="somestring"
    LINE_BREAK="\n"
    rendered_result = 'System_Boundary({id},"{descr}") {{'.format(id=id,descr=d) + LINE_BREAK
    return rendered_result

print(some_function())

If text is being added after the some_function method it will be indented approx. 58-60 spaces to right

clouddistortion avatar Feb 09 '20 08:02 clouddistortion

Works for me. Is the "{{" recognized as "pythonString" with your syntax highlighting? This should take care of skipping it: https://github.com/Vimjas/vim-python-pep8-indent/blob/b3a7395ce49b13145bbb54b1cdbfe6a33585bfe9/indent/python.vim#L369

blueyed avatar Feb 09 '20 08:02 blueyed

I think it s interpreted as a variable

screenshot

clouddistortion avatar Feb 09 '20 08:02 clouddistortion

even a simple S="{{" provokes a file indent on the next line

clouddistortion avatar Feb 09 '20 08:02 clouddistortion

Appears to be an issue with your syntax file then.

blueyed avatar Feb 09 '20 09:02 blueyed

Looks like it delegates to some other syntax maybe? What does :echo reverse(map(synstack(line("."), col(".")), 'synIDattr(v:val,"name")')) display? (or zS with vim-scriptease)

blueyed avatar Feb 09 '20 09:02 blueyed

if the cursors location is in the string with the two curly brackets it displays: ['pythonStrFormat', 'pythonString']

clouddistortion avatar Feb 09 '20 09:02 clouddistortion

So that should be ok. But there's another method used to check/skip this after all. Can you try https://github.com/Vimjas/vim-python-pep8-indent/pull/133, please? What syntax plugin/file are you using?

blueyed avatar Feb 09 '20 10:02 blueyed

I am using the configuration of https://vim.fisadev.com/ at https://raw.githubusercontent.com/fisadev/fisa-vim-config/master/config.vim

clouddistortion avatar Feb 09 '20 10:02 clouddistortion

works great!

clouddistortion avatar Feb 09 '20 10:02 clouddistortion

Cool! Will have to check this with regard to slower performance now maybe (and adding a test), but good to know already that it works.

blueyed avatar Feb 09 '20 10:02 blueyed