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

Styles[0] is incorrect #133

Closed
dpmm99 opened this issue Jul 27, 2024 · 1 comment
Closed

Styles[0] is incorrect #133

dpmm99 opened this issue Jul 27, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@dpmm99
Copy link

dpmm99 commented Jul 27, 2024

Describe the bug
I tried this in both 5.5.1 and 5.6.0.
Scintilla.Styles[0] returns inaccurate data. For example, the debugger showed that its ForeColor was Transparent when I had set it to Color.Black. The text appears correctly in the original Scintilla control, but when I copied the styles to another Scintilla control, the text was present but invisible (until I selected it).
This doesn't seem to be a problem with Styles[3] or higher (I'm not using indices 1 or 2, so I can't vouch for those.)

To Reproduce
Given an existing Scintilla control with styles configured, simply check the value of that.Styles[0]. In my case, I was using code like this spread across two different forms:

sc.StyleResetDefault();
sc.Styles[Style.Default].Font = "Consolas";
sc.Styles[Style.Default].Size = 10;
sc.StyleClearAll();
sc.Styles[0].ForeColor = Color.Black;
...
for (var x = 0; x < 10; x++) sc.Styles[x].CopyTo(newScintilla.Styles[x]);

But I also checked and found that it returns Transparent immediately after being set to Black.

Expected behavior
Styles[0] should return the properties as they were when you set them.

Desktop (please complete the following information):

  • OS: Windows 10

Additional context
I briefly checked the Scintilla.NET code and the Scintilla documentation, and nothing stuck out to me--style 0 isn't reserved, unlike 32-39. It might actually be a bug in Scintilla itself.

@dpmm99 dpmm99 added the bug Something isn't working label Jul 27, 2024
@omarigg04
Copy link

omarigg04 commented Jul 27, 2024

Hi there,
From what you've described, it sounds like there might be an inconsistency in how Scintilla is handling the styles, particularly with Styles[0].

It appears that Styles[0] is not retaining the ForeColor property correctly, showing Color.Transparent instead of Color.Black right after setting it. This issue doesn't seem to affect Styles[3] and higher, which makes it even more peculiar. Given that the text is visible once selected, it suggests that the style is applied but not rendered correctly.

You've mentioned that you observed Color.Transparent immediately after setting Color.Black. This indeed sounds like an unexpected behavior.

Expected Behavior:
As you rightly pointed out, Styles[0] should return the properties as they were set. In this case, it should retain and reflect Color.Black for the ForeColor property.

If you checked the Scintilla.NET code and the Scintilla documentation without finding anything unusual about Style 0. Given that styles 32-39 are reserved, it’s curious that Style 0 behaves differently.

Replication: I will try to replicate the issue on my end with both versions 5.5.1 and 5.6.0 to see if the behavior is consistent.
Comparison: I will compare the behavior with Styles[1] and Styles[2] to check if they exhibit the same issue.
Further Debugging: If necessary, I'll dive deeper into Scintilla’s handling of Styles[0] to pinpoint where the discrepancy might be occurring.
Environment:
OS: Windows 10 (thanks for specifying this, it helps in ensuring a consistent testing environment).
Additional Context:
Given your insights and initial checks, it might indeed be a bug in Scintilla itself rather than in Scintilla.NET. If this is the case, we might need to escalate it to the Scintilla maintainers.

Best regards,

ahmetsait added a commit to ahmetsait/Scintilla.NET that referenced this issue Jul 29, 2024
…rent colors via APIs that don't support alpha channel
desjarlais added a commit that referenced this issue Jul 29, 2024
Fix #133: Scintilla misbehaves when it receives transparent colors via APIs that don't support alpha channel
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

No branches or pull requests

2 participants