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

Fix folding in user-defined languages for non-windows line endings #3372

Closed
wants to merge 2 commits into from

Conversation

ssk97
Copy link
Contributor

@ssk97 ssk97 commented Jun 6, 2017

fixes #2873 and fixes #350 (duplicate issues)

I also replaced two instances of "true" with EOL_SKIP_CHECK since that's what it evaluates to (and to reduce confusion since "true" would imply EOL_FORCE_CHECK)

@ssk97
Copy link
Contributor Author

ssk97 commented Jun 13, 2017

Update: I realized that the previous fix was only for operators (like semicolon in C), I've now fixed it so that delimiters (like quotes) don't break the folding either.

@rmcurtis
Copy link

I'm so glad to see a fix for this! It's been bugging me for years. We even keep a bunch of files in Windows EOL format just so code folding works with our UDL. Otherwise they should be Unix EOL format.

I managed to compile Notepad++ with your changes and it works great, just like it should. Hope to see this fix in a released version soon.

Thanks again!

@donho donho self-assigned this Aug 21, 2017
@donho
Copy link
Member

donho commented Aug 26, 2017

@ivan-radic Could you validate this PR please?

@ivan-radic
Copy link

Thanks for notification @donho and thanks to @ssk97 for the fix.
I agree that "true" should be replaced with EOL_SKIP_CHECK. Variable checkEOL used to be bool, but got converted to int during development. I wonder why compiler never warned about implicit conversion??

Anyway, looking at the code variable checkEOL is used to force EOL processing when Delimiter close statement "consumes" EOL. Typical example are line comments, EOL is consumed by line comment (or delimiter that is closed by ((EOL)) special character).

Of top of my head, I don't remember why was it necessary to skip EOL processing if Delimiter open and Folding keywords that are immediately followed by EOL char, but it obviously is missing for Opetaror1 stye. Thanks @ssk97 for finding that bug. First commit should be merged into main branch.

As for second commit, it is not good:

`
if (newState != SCE_USER_STYLE_COMMENTLINE || (sc.ch != '\r' && sc.ch != '\n'))
sc.Forward(iter->length());

- if (sc.atLineStart)
- checkEOL = EOL_FORCE_CHECK;
+ if (sc.atLineEnd)
+ checkEOL = EOL_SKIP_CHECK;
`

EOL at the end of line comments is not "skipped forward" because of potential nested line comment sequence. Therefore, we can't check atLineEnd but must instead rely on atLineStart which is safe even in case of multiple nested line comments.

@ivan-radic
Copy link

Long story short: use first commit, discard second one. Some basic testing in pre-release phase by beta testers would be wise.

Best regards,
Ivan

Copy link

@IvanKostyuk IvanKostyuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes resolve the problem. Folding works well with all types of EOL (CRLF, LF, CR).

@Medal-x
Copy link

Medal-x commented Aug 13, 2018

Still not work when using "SCE_USER_STYLE_COMMENTLINE" & "SCE_USER_STYLE_DELIMITER" (1-8)
I added :
if (sc.atLineEnd) checkEOL = EOL_SKIP_CHECK;
About everywhere after:
dontMove = true;
in LexUser.cxx

Seem to work now!

@gwttk
Copy link

gwttk commented Apr 3, 2019

Can we have this at 7.6.6 please?

@donho
Copy link
Member

donho commented Aug 4, 2019

Cherry pick Fix folding in user-defined languages for non-windows line endings but ignore Fix delimiters as well as operators as @ivan-radic suggested.

kspalaiologos pushed a commit to kspalaiologos/notepad-plus-plus that referenced this pull request Jan 17, 2021
donho pushed a commit that referenced this pull request Nov 19, 2021
This fixes a bug where UDL folding breaks if 1) the file uses
non-Windows line endings and 2) delimiters are defined.

Fix #350, fix #2873, fix #3372, fix #5499, close #7930
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UDL folding issues with CR or LF only Broken folding when using LF instead of CRLF
8 participants