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

Fixes bug #23 where line number view would overlay the text view #25

Merged
merged 1 commit into from
Jan 26, 2020

Conversation

greimers
Copy link
Contributor

The main problem is, that Apple seems to have changed how rulers affect the scroll position.
Our line numbers are a ruler in the scroll view. In the past, NSScrollView would automatically inset the content so the ruler does not overlap the content. This has changed but it is unclear when.
Anyway, I did the following:

  • Made TextViewController adjust the width of the text view to take the width of the number ivew into account (subtract it)
  • Made all scrolling not scroll to (0,y) but to (lineNumberWidth, y)

@greimers greimers self-assigned this Jan 26, 2020
@greimers
Copy link
Contributor Author

This might break behaviour on very old macOS systems but we have no way to test it.

Copy link
Contributor

@jpeinelt jpeinelt left a comment

Choose a reason for hiding this comment

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

seems to work perfectly (on catalina at least, but what can we do)

@@ -141,7 +143,7 @@ - (IBAction) search: (id) sender {
if (foundRange.location != NSNotFound) {
NSRect boundingRect = [[self.textView layoutManager] boundingRectForGlyphRange:foundRange inTextContainer:[self.textView textContainer]];
NSPoint scrollPoint = NSMakePoint(0, boundingRect.origin.y);
[self scollToPoint:scrollPoint];
[self scrollToPoint:scrollPoint];
Copy link
Contributor

Choose a reason for hiding this comment

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

😀

@greimers greimers merged commit 9d9b427 into master Jan 26, 2020
@greimers greimers deleted the fix/23-line-number-view-overalys-text branch November 14, 2021 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants