-
Notifications
You must be signed in to change notification settings - Fork 103
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
Problems with NSTextList and NSParagraphStyle isEqual: implementations #294
Comments
To see what I mean about it causing paragraph styles to be merged together when they shouldn't, see the following:
In the log output:
Note that we put in two paragraph styles with different list items (0x556ea83960c0 and 0x556ea83acaa0), but only get the one paragraph style instance back (0x556ea83960c0) because of the incorrect merging. If you uncomment the section in the example, this won't happen because the |
Thank you for these great observations. The problem here is that nobody else seems to be using NSTextList at the moment on GNUstep. Otherwise these issues would have been noticed before. It would be great if you could contribute fixes. The best way is to provide a pull request on GitHub and it would even be better if that included a test for the functionality. |
@fredkiefer, I'll try to get libs-gui building locally and see if I can send a PR over for this and the other two issues (#293, #294, #295). I hope to have a chance to work on it soon. I've actually been quite impressed with GNUStep so far (it reminds me of how much I enjoyed programming in Cocoa on Mac OS 10.4 many years ago). If nobody's been using it for applications that are heavy on text editing, I doubt anyone would have found the issue. |
The implementation of
isEqual:
for NSTextList and NSParagraphStyle needs to be reconsidered. As a practical matter it causes problems with list handling in NSTextViews/NSTextStorage.(I'd also be happy to submit some PRs on these if nobody else is interested, but at this time, I've just started playing with GNUStep and don't have it building locally. The three issues I'm reporting are all interrelated to some degree in terms of their effects.)
NSTextList
For NSTextList on GNUStep, we do the following and compare some of the member fields:
libs-gui/Source/NSTextList.m
Lines 54 to 67 in fb61a0f
On the other hand, Cocoa itself seems to treat each NSTextList as unique, even if they have the same values:
On Cocoa this prints 0 but on GNUStep it prints 1. I suspect the Cocoa implementation's
isEqual:
only looks to see if they're the exact same object, which makes sense. Two lists might have the same values (marker format, starting value) but they would still be fundamentally different lists. (This also relates to the below topic.)NSParagraphStyle
For NSParagraphStyle it currently doesn't include the
textLists
as part of the equality test:libs-gui/Source/NSParagraphStyle.m
Lines 597 to 625 in fb61a0f
That appears to be causing a problem where NSParagraphStyle runs in attributed strings get merged together when they shouldn't. In this case it can happen when adjacent paragraph styles differing only by lists end up getting combined when they shouldn't, but it could conceivably happen in other situations as well (text blocks perhaps?).
Note that adding the
textLists
to the comparison here won't have any effect unless the NSTextList comparison itself is fixed to treat each instance as unique.The text was updated successfully, but these errors were encountered: