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

Highlighter highlights all lines inside folded regions #4687

Closed
annikovk opened this issue May 5, 2022 · 10 comments
Closed

Highlighter highlights all lines inside folded regions #4687

annikovk opened this issue May 5, 2022 · 10 comments

Comments

@annikovk
Copy link

annikovk commented May 5, 2022

I have serveral big folded regions (several thousand lines) stay one after another:
image

Once I search something, highlighter is invoked to highlight all of the found strings: https://github.com/ajaxorg/ace/blob/master/lib/ace/ext/searchbox.js#L266

During the highlighting process, it takes editor's visible rows, and draws single line markers for every found range within visible rows.

So, the problem is the fact that Ace thinks that rows inside folded regions are visible and tries to add markers for all of them:

image

This causes UI freezes during the search: JetBrains/IntelliJ-Log-Analyzer#11
The only workaround I found is to unfold all regions, which is not acceptable.

@andrewnester
Copy link
Contributor

@annikovk could you please provide a minimal code so we can easier reproduce this issue? Thank you

@annikovk
Copy link
Author

annikovk commented May 11, 2022

  1. Open your sample editor (https://ace.c9.io/build/kitchen-sink.html),
  2. Enable editor's gutter
  3. Search for 'alert' word
  4. Collapse the region with 'alert' word in the editor
  5. Focus search input to highlight all occurrences of 'alert' word
  6. The selected-word node (which highlights 'alert' word) is not removed on code block folding despite the fact it is invisible:

image

The problem is: in case there are thousands of such nodes collapsed, ace editor freezes.

@annikovk
Copy link
Author

@andrewnester have you been able to reproduce that?
Is it a confirmed bug now?

@andrewnester
Copy link
Contributor

@annikovk haven't looked at reproducing it yet, will update once we know the details, but it looks like it should be clear to reproduce

@andrewnester andrewnester self-assigned this May 23, 2022
@andrewnester
Copy link
Contributor

@annikovk you mentioned

The only workaround I found is to unfold all regions, which is not acceptable.

How does unfolding help in this case? These selected word elements are still there, right?

@annikovk
Copy link
Author

I am trying to eliminate the freeze. And the freeze happens in case there are thousands of selected words inside the folded region, which is inside visible area of the editor

unfolding helps to move selected elements out of visible region, so they are removed from DOM

Let me know if it is needed to describe that in more details with screenshots.

@andrewnester
Copy link
Contributor

Okay, got it!
I guess we indeed should just have 1 selected word dom element when the code is collapsed, there is no need to have them overlap.
I guess the reason we have is not to add / remove dom elements when code folds for performance reasons but it also seems like it already causes performance issues :)

I’ll try to work on PR for this

@andrewnester
Copy link
Contributor

@annikovk could you please check if your issue is solved here? https://raw.githack.com/andrewnester/ace/bug/4687/kitchen-sink.html

@annikovk
Copy link
Author

annikovk commented May 30, 2022

Yes, 100% working as in my dreams. Thank you!

@andrewnester
Copy link
Contributor

We just merged the PR and released new 1.5.2 version containing the fix

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

No branches or pull requests

2 participants