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

Improve line numbers #2470

Merged
merged 14 commits into from
Jan 18, 2025
Merged

Conversation

guanglinn
Copy link
Contributor

Refactor this feature:

  • Improve line numbers experience
  • Optimize algorithm of drawing line numbers

@guanglinn
Copy link
Contributor Author

guanglinn commented Nov 6, 2024

The line numbers is fixed to the left.

Before

2024-11-07-line-numbers.mp4

Now

2024-11-07-line-numbers-fixed.mp4

{
if (_lineNumbersView.isLineNumbersEnabled()) {
final long time = System.currentTimeMillis();
if (time - _lineNumbersRefreshTime > 125) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why a time based vs a scroll based refresh like we do now?

Copy link
Contributor Author

@guanglinn guanglinn Nov 10, 2024

Choose a reason for hiding this comment

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

The time based code just reduces the refresh rate of line numbers when scrolling.

Copy link
Collaborator

Choose a reason for hiding this comment

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

But we already have a system where the line numbering only redraws after the user has scrolled by some delta (1 page iirc). IMO that is superior

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That system is called passively when the view is changed, it works well when the view is EditText, but now this view is TextView. So this code is designed to actively trigger that system to check and determine whether to draw new line numbers.

Copy link
Owner

Choose a reason for hiding this comment

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

How well does it work on bigger files (old and new)? Redrawing partial should work better, isn't it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I think it's better than before.

2025-01-03-line-numbers-33000-lines.mp4

@guanglinn guanglinn changed the title Enhance line numbers Improve line numbers Dec 7, 2024
@gsantner gsantner added this to the Markor v2.14 milestone Jan 18, 2025
Copy link
Owner

@gsantner gsantner left a comment

Choose a reason for hiding this comment

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

Thank you!

Merging

@gsantner gsantner merged commit abdefb0 into gsantner:master Jan 18, 2025
1 check passed
@guanglinn guanglinn deleted the refactor_line_numbers branch January 19, 2025 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants