EngStan
EngStan

Reputation: 383

Excluding module level comments from folding

I am trying to add some comments starting on the first column of my module, in order to categorise the functions within the code and improve readability.

The issue I have is that Pydev seems to include these comments within the folding of the function above the comment (see the picture below). Is there a way that I can exclude these comments that are on the same level as the function from the function folding?

Function folding issue

Upvotes: 1

Views: 45

Answers (1)

Fabio Zadrozny
Fabio Zadrozny

Reputation: 25342

There's currently no way to customize this behavior (comments are a bit tricky because they don't appear as actual nodes in the grammar).

The related code in PyDev is in:

org.python.pydev.parser.visitors.scope.CodeFoldingVisitor org.python.pydev.editor.codefolding.CodeFoldingSetter

I guess the place which creates the folding marks could check whether a comment is in the last lines of a folding mark in the same level when right next to the declaration of a different class/method and exclude it (there are cases where that comment should enter as I've seen people add comments in the end of a class related to it -- for instance I've seen comments as # end if or #end class on big if statements or classes, but those are usually not "glued" to the next declaration -- as a note, the endLine is explicitly set to include the comments after in org.python.pydev.parser.visitors.scope.EasyAstIteratorBase.after(ASTEntry), but this is probably not fixable there).

You can report that at https://www.brainwy.com/tracker/PyDev -- although I don't know when I'll be able to tackle it, so, if you're up to provide a pull request -- see: http://www.pydev.org/developers.html for how to get the code -- it could be integrated much sooner ;)

Upvotes: 1

Related Questions