Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions CodeEdit/SideBar/SideBarItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,15 @@ struct SideBarItem: View {

func sidebarFolderItem(_ item: WorkspaceClient.FileItem) -> some View {
DisclosureGroup(isExpanded: $isExpanded) {
if isExpanded { // Only load when expanded -> Improves performance massively
if !isExpanded {
// Only load the labels
ForEach(item.children!.sortItems(foldersOnTop: workspace.sortFoldersOnTop)) { child in
Label(child.url.lastPathComponent, systemImage: child.systemImage)
.accentColor(child.iconColor)
.font(.callout)
}
} else {
// Only load when expanded -> Improves performance massively
ForEach(item.children!.sortItems(foldersOnTop: workspace.sortFoldersOnTop)) { child in

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is actually required since in a very large project folder this will load all children all the time which leads to very long file opening times.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Screen.Recording.2022-03-18.at.15.59.15.mov

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

It breaks the animation.

Maybe it's an idea to only place the labels, and then update them?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If you can figure something out that doesn't break performance that'd be awesome. So far this if clause was the best option I found

@0xWDG 0xWDG Mar 18, 2022 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

So instead of

SideBarItem(item: child,
workspace: workspace,
windowController: windowController)

We should use?

SideBarItem(item: child,
workspace: workspace,
windowController: windowController,
loadSubitems: isExpanded)

Or (maybe the worst solution)

Text(child.name) // Don't know is child.name exists. its pseudo code

@0xWDG 0xWDG Mar 18, 2022 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Ah, I see, the issue is, when you open a file, it's rendering the whole file tree again.

This should

  1. be done on the background
  2. or not at all when opening a file

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That's what I suspected as well

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ok I just tested the latest commit and it seems to run very nice. Couldn't see performance losses to before.

@0xWDG 0xWDG Mar 18, 2022 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Ok, after some research, opening/closing doesn't trigger an update.
selecting a file does.

There seems to be a delay again when opening files from that video

This has been fixed with commit 6dfa149

6dfa149 (for refrerence, clickable)

This commit increases the speed, but this is not the solution, the problem is that this bar is getting re-rendered when you open/select a file.
if you disable this if, and only open and close the disclosure groups, then it works as expected.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

SwiftUI acts strangely sometimes…

SideBarItem(item: child,
workspace: workspace,
Expand All @@ -54,6 +62,6 @@ struct SideBarItem: View {
Label(item.url.lastPathComponent, systemImage: item.systemImage)
.accentColor(.secondary)
.font(.callout)
}
}
}
}