Styles[0] is incorrect
Closed this issue · 1 comments
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.
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,