Skip to content
This repository has been archived by the owner on Jul 27, 2023. It is now read-only.

Added boundaries for scrolling #43

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Added boundaries for scrolling #43

wants to merge 1 commit into from

Conversation

antoninklopp
Copy link

This is a really small contribution because I am beginning to use xi-win but I decided to change the boundaries for scrolling, not allowing to scroll when the text is smaller than the window size. It seems more normal to me this way.

Copy link
Collaborator

@LiHRaM LiHRaM left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution!
I started a review but posted before I'd finished, so I'm doing it again properly. (In case you were confused about my disappearing comment.)

This is probably the kind of feature that a user should be able to toggle. xi-win doesn't have preferences right now, so your change might have to wait.

However, I have no idea how Raph feels about this, and it might very well be accepted by him.

(self.line_cache.height().saturating_sub(1)) as f32) - self.size.1 + LINE_SPACE;

// Not allowing to scroll if the text is smaller than the window size
if (LINE_SPACE * self.line_cache.height().saturating_sub(1) as f32) < self.size.1 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: You're performing this calculation and typecast twice - might want to store it in a variable instead?
e.g. let visible_lines = LINE_SPACE * self.line_cache.height().saturating_sub(1) as f32

Copy link
Author

Choose a reason for hiding this comment

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

Storing the calculation in a variable would be a better idea of course !


// Not allowing to scroll if the text is smaller than the window size
if (LINE_SPACE * self.line_cache.height().saturating_sub(1) as f32) < self.size.1 {
max_scroll = 0 as f32;
Copy link
Collaborator

Choose a reason for hiding this comment

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

This seems to lock the last line at the bottom of the screen if you have something larger than your screen. Was that the behavior you wanted?

Copy link
Author

@antoninklopp antoninklopp Oct 7, 2018

Choose a reason for hiding this comment

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

Yes it was the behavior wanted. Maybe, it should have some extra lines at the end, but I think that this is pretty common behavior for most text editors.

@raphlinus
Copy link
Member

For what it's worth I prefer this behavior, but it seems to be a preference, with the existing behavior default on Windows on Sublime Text. There's no preference infrastructure in place yet. What I'd like is a bool that's set to a const value (Sublime calls it scroll_past_end) and then an if statement that allows both behaviors.

The current behavior of showing a blank screen is going to be mitigated when there are line numbers.

Thanks for the contribution!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants