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

When opening and closing folders with many files in the sidebar, it takes longer than it should. #1711

Open
kishikawakatsumi opened this issue Sep 16, 2024 · 1 comment
Assignees
Labels
better to fix unwanted behaviors better to fix

Comments

@kishikawakatsumi
Copy link

Description

When opening and closing folders with many files (2000 files for debug builds, 4000 to 8000 for release builds to reproduce) in the sidebar, it takes longer than expected.

Screen.Capture.2024-09-17.5.01.54.mp4

This is because NSOutlineView calls outlineView(_:child:ofItem:) (and related functions) for ALL elements.

When an element is expanded or collapsed, contrary to our intuition, NSOutlineView calls the delegate method for all elements, not just the visible ones, (presumably to maintain the element's expanded/collapsed state).

So delegate methods called at this time needs to complete as quickly as possible.

In this case I recommend using a very short term cache that is only valid while element expansion or collapse operation.

To Reproduce

  1. Create a directory named test
  2. Create many files in the directory. e.g. touch test{0001..2000}.dat
  3. Open the parent directory of the test directory.
  4. Expand/collapse test directory in the sidebar.

Expected behavior

The time taken to expand and collapse folders is not proportional to the amount of files.

CotEditor version

Version 5.0.0-rc (666)

macOS version

14.6.1 (23G93)

Additional context

No response

@kishikawakatsumi kishikawakatsumi added the potential bug issues not yet tested label Sep 16, 2024
@1024jp 1024jp added better to fix unwanted behaviors better to fix and removed potential bug issues not yet tested labels Sep 16, 2024
@1024jp 1024jp self-assigned this Sep 16, 2024
@1024jp 1024jp added this to the 5.0.1 milestone Sep 17, 2024
@1024jp
Copy link
Member

1024jp commented Sep 17, 2024

Thank you for the feedback.
Well, that needs to be improved.

In this case I recommend using a very short term cache that is only valid while element expansion or collapse operation.

Thank you even for the recommendation. However, I feel it's a bit dangerous when the user expands multiple folders at once (with the Option+ shortcut).
It, of course, depends on where and how we make the cache, though.

Looking ahead to future features like file filtering, I now feel it's better to have another tree (or children) only for the presentation.
Let me think.

@1024jp 1024jp removed this from the 5.0.1 milestone Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
better to fix unwanted behaviors better to fix
Development

No branches or pull requests

2 participants