Skip to content

Conversation

gadfly3173
Copy link
Contributor

@gadfly3173 gadfly3173 commented Apr 26, 2024

Partial repair #86

  • added force refresh branches and commits after operated branch.
  • fixed watcher

Known Issues:

  • Operate branch and commit in other worktree repo(includes base repo) still won't show in current worktree repo. To solve this may need to add refresh branches and commits after switched repo tab.
  • Manually press FETCH button won't fix above question.
@love-linger
Copy link
Collaborator

commit 27fd582 will not be merged because it will introduce some issues:

  • If you pressed middle button on the tab but release it outside the tab-bar, the _middleButtonPressed will never be reset to false
  • If you pressed middle button on one tab but release it on another tab, the behaviour is very strange.
@love-linger
Copy link
Collaborator

According to the code in Models/Watcher.cs:

if (_updateBranch > 0 && now > _updateBranch) { _updateBranch = 0; _updateWC = 0; if (_updateTags > 0) { _updateTags = 0; Task.Run(() => { _repo.RefreshTags(); _repo.RefreshBranches(); _repo.RefreshCommits(); }); } else { Task.Run(() => { _repo.RefreshBranches(); _repo.RefreshCommits(); }); } Task.Run(_repo.RefreshWorkingCopyChanges); }

Repository.RefershBranches and Repository.RefreshCommits will always be called if the state of branch changes. If you want to run it immediately, I suggest you use Repository.MarkBranchesDirtyManually in UIThread instead. For example:

- CallUIThread(() => _repo.SetWatcherEnabled(true)); - if (!CheckoutAfterCreated) - { - _repo.RefreshBranches(); - _repo.RefreshCommits(); - } + CallUIThread(() => { + repo.SetWatcherEnabled(true); + repo.MarkBranchesDirtyManually(); + }); return true;
@love-linger
Copy link
Collaborator

By the way, would adding a toolbar button to refresh the entire repository (shortcut F5) help with these and other similar issue?

@gadfly3173
Copy link
Contributor Author

I'll continue to work on this after April 30th.

@love-linger love-linger force-pushed the develop branch 2 times, most recently from 758e0fb to 9a68418 Compare April 27, 2024 13:13
@love-linger
Copy link
Collaborator

There are already three ways to close tabs.

  • Click the close button on each tab (with left mouse button)
  • Use context menu of each tab (with right mouse button)
  • Use hotkey CTRL + W

I really do NOT want to introduce a nother way that using the mouse middle button……

@gadfly3173
Copy link
Contributor Author

gadfly3173 commented Apr 28, 2024

There are already three ways to close tabs.

  • Click the close button on each tab (with left mouse button)
  • Use context menu of each tab (with right mouse button)
  • Use hotkey CTRL + W

I really do NOT want to introduce a nother way that using the mouse middle button……

Using the middle button to close a tab is a very common design in other multi-tab applications, such as Chrome, Jetbrains IDE, Visual Studio Code, GitKraken, etc. I will still revert the submit about closing the tab because it has nothing to do with this PR, and I may not be able to solve the aforementioned error performance

@love-linger love-linger self-assigned this Apr 29, 2024
@love-linger love-linger added the enhancement New feature or request label Apr 29, 2024
@gadfly3173
Copy link
Contributor Author

Known Issues:

  • Operate branch and commit in other worktree repo(includes base repo) still won't show in current worktree repo. To solve this may need to add refresh branches and commits after switched repo tab.
  • Manually press FETCH button won't fix above question.

Fixed these issues

@love-linger
Copy link
Collaborator

love-linger commented May 3, 2024

Commit a63a0d1 force refreshing branches, working copy changes and commit after current active page changed. It's not recommanded. I've add a hotkey 'F5' to manually refresh the whole repository if it is needed.

@gadfly3173
Copy link
Contributor Author

Commit a63a0d1 force refreshing branches, working copy changes and commit after current active page changed. It's not recommanded. I've add a hotkey 'F5' to manually refresh the whole repository if it is needed.

Why is it not recommended to refresh branches, commits, and workspaces after switching repositories? According to my observation, GitKraken takes this approach.

@love-linger
Copy link
Collaborator

I've pushed a commit 1fe050e to fix issue #86.

Because we use filesystem watcher to determine how to refresh the information of repository, it's not necessary to refresh the repository each time we switch between tabs.

And since Worktree can be traited as : checkout a branch of the main repository to another directory, we just need to make sure that Worktree also listens for gitdir changes in the main repository (since worktree is essentially the same repository as the main Repository) to resolve the issue.

@gadfly3173 gadfly3173 closed this May 3, 2024
@gadfly3173 gadfly3173 deleted the fix/worktree branch May 3, 2024 13:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

2 participants