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

Minor Bug in set Scintilla.LexerName #30

Closed
RobSwDev opened this issue Jan 10, 2023 · 4 comments · Fixed by #31
Closed

Minor Bug in set Scintilla.LexerName #30

RobSwDev opened this issue Jan 10, 2023 · 4 comments · Fixed by #31
Assignees
Labels
bug Something isn't working
Milestone

Comments

@RobSwDev
Copy link
Contributor

If SetLexerByName(value) fails, then lexerName is not yet set, and so not reported (or the previous version is reported) in the exception message.

            set
            {
                if (string.IsNullOrWhiteSpace(value))
                {
                    lexerName = value;

                    return;
                }

                #if SCINTILLA5
                if (!SetLexerByName(value))
                {
                    throw new InvalidOperationException(@$"Lexer with the name of '{lexerName}' was not found.");
                }
                #elif SCINTILLA4
                if (NativeMethods.NameConstantMap.ContainsValue(value))
                {
                    Lexer = (ScintillaNET.Lexer) NativeMethods.NameConstantMap.First(f => f.Value == value)
                        .Key;
                }
                #endif

                lexerName = value;
            }
@VPKSoft
Copy link
Contributor

VPKSoft commented Jan 10, 2023

Thanks for reporting this - I'll check this out...

@VPKSoft VPKSoft self-assigned this Jan 12, 2023
@VPKSoft VPKSoft added the bug Something isn't working label Jan 12, 2023
@VPKSoft VPKSoft added this to the v.5.x.y milestone Jan 12, 2023
@VPKSoft
Copy link
Contributor

VPKSoft commented Jan 12, 2023

Hi,
Could you provide steps to reproduce this. The SetLexerByName method is private so it is not part of the public "API".
So what I need to do to reproduce the issue.
An exception is thrown correctly if the lexer name is not found. E.g. not supported by the Scintilla native.

@RobSwDev
Copy link
Contributor Author

Apologies - it wasn't terribly clear.

I mean, if you set the public LexerName property to an invalid value, the exception is correctly thrown, but the exception message is incorrect - it uses the private field lexerName.
But lexerName has not yet been set to the new (and invalid) value value, so the wrong name is reported. The message should report value as the invalid name.

In my case, lexerName was null, and so the invalid name was reported as an empty pair of quotes.

@VPKSoft VPKSoft linked a pull request Jan 12, 2023 that will close this issue
@VPKSoft
Copy link
Contributor

VPKSoft commented Jan 12, 2023

Hi,
Thanks for the additional info, fixed, closed and released a new version 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants