Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Indention not working after using escaped { #132

Open
clouddistortion opened this issue Feb 7, 2020 · 12 comments · May be fixed by #133
Open

Indention not working after using escaped { #132

clouddistortion opened this issue Feb 7, 2020 · 12 comments · May be fixed by #133
Labels

Comments

@clouddistortion
Copy link

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

@blueyed
Copy link
Member

blueyed commented Feb 7, 2020

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.. ;)

@clouddistortion
Copy link
Author

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

@blueyed
Copy link
Member

blueyed commented Feb 9, 2020

Works for me.
Is the "{{" recognized as "pythonString" with your syntax highlighting?
This should take care of skipping it:

\ "synIDattr(v:val, 'name')"), 'python\S*String') == -1

@clouddistortion
Copy link
Author

I think it s interpreted as a variable

screenshot

@clouddistortion
Copy link
Author

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

@blueyed
Copy link
Member

blueyed commented Feb 9, 2020

Appears to be an issue with your syntax file then.

@blueyed
Copy link
Member

blueyed commented Feb 9, 2020

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)

@clouddistortion
Copy link
Author

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

blueyed added a commit to blueyed/vim-python-pep8-indent that referenced this issue Feb 9, 2020
@blueyed blueyed linked a pull request Feb 9, 2020 that will close this issue
2 tasks
@blueyed
Copy link
Member

blueyed commented Feb 9, 2020

So that should be ok. But there's another method used to check/skip this after all.
Can you try #133, please?
What syntax plugin/file are you using?

@clouddistortion
Copy link
Author

@clouddistortion
Copy link
Author

works great!

@blueyed
Copy link
Member

blueyed commented Feb 9, 2020

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 blueyed added the bug label Feb 9, 2020
blueyed added a commit to blueyed/vim-python-pep8-indent that referenced this issue Mar 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants