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

Multi-line Strings #22

Closed
qguv opened this issue Mar 28, 2014 · 2 comments
Closed

Multi-line Strings #22

qguv opened this issue Mar 28, 2014 · 2 comments

Comments

@qguv
Copy link

qguv commented Mar 28, 2014

SimpylFold doesn't properly handle multi-line strings, especially important in test-driven development.

For example:

    def testIndexToCoord(self):
        m = '''Wrong coordinate given from index. Check indexToCoord() method.

Index given: {}
Observed coordinate: {}
Expected coordinate: {}'''
        index = 3
        expectedCoord = (0, 1)

becomes

+--  2 lines: def testIndexToCoord(self):--------------------------------------------------------------

Index given: {}
Observed coordinate: {}
Expected coordinate: {}'''
        index = 3
        expectedCoord = (0, 1)
@mgedmin
Copy link

mgedmin commented May 21, 2015

A workaround that I use is to wrap the multi-line string in textwrap.dedent():

    def testIndexToCoord(self):
        m = textwrap.dedent('''\
            Wrong coordinate given from index. Check indexToCoord() method.

            Index given: {}
            Observed coordinate: {}
            Expected coordinate: {}''')
        index = 3
        expectedCoord = (0, 1)

@tmhedberg
Copy link
Owner

Reliably detecting this kind of case without actually implementing a full Python parser in Vim would be difficult if not impossible. This kind of edge case is pretty much always going to trip up the folding algorithm. It is a legitimate bug, but it's not likely to be fixed, because it would require an overhaul to how the plugin works, making it much more complicated. The existing algorithm is simple, pretty fast, and "good enough" in most cases, but will never be perfect.

@qguv qguv closed this as completed May 24, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants