summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlhchavez <lhchavez@lhchavez.com>2021-01-20 04:40:40 -0800
committerlhchavez <lhchavez@lhchavez.com>2021-01-20 04:40:40 -0800
commit2f382ab74b7b8568b47e118f1802763a911b84e3 (patch)
tree7ef4ab72292fff7a8d8d84a50ea0ea8be691446e
parent3392da3ce49853057288009367df3d48d9d0d6f9 (diff)
downloadlibgit2-2f382ab74b7b8568b47e118f1802763a911b84e3.tar.gz
mwindow: Fix a bug in the LRU window finding code
This change now updates the `lru_window` variable to match the current file's MRU window. This makes it such that it doesn't always choose the file that happened to come last in the list of window files, and instead should now correctly choose the file with the least-recently-used one.
-rw-r--r--src/mwindow.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/mwindow.c b/src/mwindow.c
index 7832d9c8b..5fcae2eed 100644
--- a/src/mwindow.c
+++ b/src/mwindow.c
@@ -312,8 +312,10 @@ static int git_mwindow_find_lru_file_locked(git_mwindow_file **out)
current_file, &mru_window, NULL, true, GIT_MWINDOW__MRU)) {
continue;
}
- if (!lru_window || lru_window->last_used > mru_window->last_used)
+ if (!lru_window || lru_window->last_used > mru_window->last_used) {
+ lru_window = mru_window;
lru_file = current_file;
+ }
}
if (!lru_file) {