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

Fixed lines not be highlighted sometimes #284

Merged
merged 3 commits into from
Oct 25, 2022
Merged

Fixed lines not be highlighted sometimes #284

merged 3 commits into from
Oct 25, 2022

Conversation

danipen
Copy link
Collaborator

@danipen danipen commented Oct 25, 2022

Fixed a condition that caused that some lines were not highlighted until they were re-created.

  • Open a document of, let's say 500 lines and go to line 400 (visible range is 400-450).
  • Open a document of 100 lines (first line is visible).
  • When the TMModel starts to emit tokens, the visual lines haven't been constructed yet.

So _firstVisibleLineIndex and _lastVisibleLineIndex are not updated and still 400 and 450. So this condition avoids not post to the dispatcher the redraw

    bool changedLinesAreNotVisible =
        (firstChangedLineIndex < _firstVisibleLineIndex && lastChangedLineIndex < _firstVisibleLineIndex) ||
        (firstChangedLineIndex > _lastVisibleLineIndex && lastChangedLineIndex > _lastVisibleLineIndex);

        if (changedLinesAreNotVisible)
            return;

Solution:
Just initialize control a flag _areVisualLinesValid and check it to calculate if changedLinesAreNotVisible.
Otherwise, post all the redraw events to the dispatcher to ensure that lines are redrawn after transforming them.

Copy link

@miryamGSM miryamGSM left a comment

Choose a reason for hiding this comment

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

LGTM

@danipen danipen merged commit a083fb5 into master Oct 25, 2022
@Takoooooo Takoooooo deleted the fix-syntax-issue branch November 30, 2022 14:25
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.

2 participants