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

Multiline comments don't work for Python #2799

Closed
sej7278 opened this issue Apr 23, 2021 · 3 comments
Closed

Multiline comments don't work for Python #2799

sej7278 opened this issue Apr 23, 2021 · 3 comments

Comments

@sej7278
Copy link

sej7278 commented Apr 23, 2021

In filetypes.python we have:

# single comment char, like # in this file
comment_single=#\s
# multiline comments
comment_open="""
comment_close="""

But none of these multi-line examples results in a comment or even heredoc, its just a string.

For some reason python syntax highlighting is ignoring comment_open/close and treating block comments as multiline comments:

screenshot

So how do we get docstrings to show up as multiline comments?

@elextr
Copy link
Member

elextr commented Apr 24, 2021

The highlighting lexer comes from a different project Scintilla and doesn't know about settings in filetypes.python. The settings in filetypes.python are only used by the various comment insert functions in Geany.

If the Python lexer makes multi-line strings a different syntax entity to single quote strings you can adjust the colour scheme to show them differently, otherwise you will need to teach the lexer in Scintilla to parse them as different entities.

[Edit: you might need to change the mapping in filetypes.python first if it maps different entities to the same named style]

@sej7278
Copy link
Author

sej7278 commented Apr 24, 2021

A lot of issues with Geany seem to come from Scintilla (like this 11 year old one); is there any alternative being looked into - like GtkSourceView or something?

@elextr
Copy link
Member

elextr commented Apr 24, 2021

Docstrings are syntactically strings see so they will show as that, the fact that they are considered docstrings is actually just a convention, and not part of the Python language at all. So greater semantic analysis would be needed to identify docstrings if they were to be highlighted differently. And they seem to be highlighted the same as all other strings in gedit too (a GTKsourceview editor).

Compare the speed of a GTKsourceview based editor and a Scintilla based editor opening a large file, Scintilla is much faster to highlight than gtksourceview, thats because Scintilla lexers are C++ not regexen. But that does allow the possibility for smarter lexers too, but "somebody" has to write them and C++ takes more effort.

Scintilla supports lots of languages and its unreasonable to expect the maintainer to support them all.

So clearly the Scintilla issue 1078 is not important enough for anyone to contribute a fix after the maintainer didn't. Scintilla (and Geany) rely on volunteers to support various languages, so if nobody volunteered the fix its not causing enough problems.

@sej7278 sej7278 closed this as completed Apr 24, 2021
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

2 participants