Commit 9210461038d7a5d0ef459f80b51a15a1465cb62d

lhchavez 2021-01-20T04:40:40

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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
diff --git a/src/mwindow.c b/src/mwindow.c
index ac26452..6e0c4d5 100644
--- a/src/mwindow.c
+++ b/src/mwindow.c
@@ -295,8 +295,10 @@ static int git_mwindow_close_lru_file(void)
 				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) {