-
Notifications
You must be signed in to change notification settings - Fork 56
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
Folding bad style #68
Comments
There are a multitude of cases like this where "bad style" which is
technically valid Python syntax results in incorrect folding. That's
because SimpylFold doesn't implement an actual parser for the Python
grammar, but rather approximates it by following indentation cues.
Building an actual parser into the script is not something I'm interested
in doing; it would not be simple anymore, to say the least. So I don't
attempt to handle this kind of thing, and as a result, we have to live with
cases like this one. My usual response, as you pretty much surmised, is
that if one's bad style confuses the algorithm, perhaps one should reform
one's style. :)
That being said, if there are syntactic constructs which are *recommended*
by PEP 8 which the script folds incorrectly, I'd consider that a bug.
On Dec 29, 2016 15:58, "Iago-lito" <[email protected]> wrote:
Currently working on this feature suggestion
<#67>, I find myself puzzled
with one case: SimpylFold is misfolding this script:
def method(argument):
here_is = code
here_is = {'kind': 'of a',
'nasty': 'case',
'uh?': 'I know'}
here_is = more_code
after_the_method
.. this is because the user is free to choose the indentation level as long
as this opening bracket { is not closed, so Simpyl algorithm stumbles over
the 6th line, considered as the end of the function.
This is misfolded. But this is bad python style.
What is Simpyl philosophy regarding this?
Is it considered as a bug? Or is it user's responsibility to respect PEP
standards so its script is folded right?
What is the philosophy I should stick to? :)
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#68>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AARxGTUCRDuct8Qcs9FvJbonEWAYQ1tbks5rNB8PgaJpZM4LX14V>
.
|
Understood. Let's drop these nasty cases then. Cheers :) Philosophy corner: Concerning the "actual parser".. I think that parsing python script would not be such a pain if we accept not sticking to plain vimscript. For instance, python's native However, nothing would work if the script is misformed (the parsing would fail). But Simpyl is all about script edition, and it is natural to have misformed script while editing script. My point is: the reason we do not want Simpyl to perform an actual parsing is not because it would make it not "simpel" anymore. It is because it would not be able to fold script during the edition process.. which is a really good reason ;) |
Yeah, you're totally correct about parsing being easier if we use a
different language. But it does come with the downside that you mention,
plus wouldn't work with a version of Vim that doesn't include the Python
scripting feature, which is another (fairly minor) disadvantage.
As long as users follow reasonable indentation practices, this script
should cover 99% of cases as-is, and I'm satisfied with that.
On Dec 30, 2016 04:29, "Iago-lito" <[email protected]> wrote:
Understood. Let's drop these nasty cases then. Cheers :)
------------------------------
Philosophy corner: Concerning the "actual parser"..
I think that *parsing* python script would not be such a pain if we accept
not sticking to plain vimscript. For instance, python's native ast
<https://docs.python.org/3/library/ast.html> package does a really good job
in this way.
*However*, nothing would work if the script is misformed (the parsing would
fail). But Simpyl is about script *edition*, and it is natural to have
misformed script while *editing* script.
My point is: the reason we do not want Simpyl to perform an actual *parsing*
is *not* because it would make it not "simpel" anymore. It is because it
would not be able to fold script *during the edition process*.. which is a
really good reason ;)
------------------------------
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#68 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AARxGfCYlABkLAEcv2YXJM4dV0owfYVYks5rNM8SgaJpZM4LX14V>
.
|
Currently working on this feature suggestion, I find myself puzzled with one case: SimpylFold is misfolding this script:
.. this is because the user is free to choose the indentation level as long as this opening bracket
{
is not closed, so Simpyl algorithm stumbles over the 6th line, considered as the end of the function.This is misfolded. But this is bad python style.
What is Simpyl philosophy regarding this?
Is it considered as a bug? Or is it user's responsibility to respect PEP standards so its script is folded right?
What is the philosophy I should stick to? :)
The text was updated successfully, but these errors were encountered: