From e54a6c594e5b1539f8a1a2a3b259a266c4f1cee0 Mon Sep 17 00:00:00 2001
From: guinux <nuxgui@gmail.com>
Date: Sat, 5 May 2018 09:20:51 +0200
Subject: [PATCH] fix #430

---
 src/alpm_config.vala        |  3 ++-
 src/preferences_dialog.vala | 14 +++++++++++++-
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/src/alpm_config.vala b/src/alpm_config.vala
index 96f7f773..01bfbdb3 100644
--- a/src/alpm_config.vala
+++ b/src/alpm_config.vala
@@ -362,7 +362,8 @@ public class AlpmConfig {
 							} else {
 								data += "IgnorePkg   = %s\n".printf (val);
 							}
-							new_conf.remove ("IgnorePkg");
+							// simply comment other IgnorePkg lines
+							new_conf.replace ("IgnorePkg", "");
 						} else {
 							data += line + "\n";
 						}
diff --git a/src/preferences_dialog.vala b/src/preferences_dialog.vala
index 02bffb25..42568851 100644
--- a/src/preferences_dialog.vala
+++ b/src/preferences_dialog.vala
@@ -254,9 +254,16 @@ namespace Pamac {
 			}
 			transaction.get_installed_pkgs.begin ((obj, res) => {
 				var pkgs = transaction.get_installed_pkgs.end (res);
+				// make a copy of ignorepkgs to store uninstalled ones
+				string[] ignorepkgs = transaction.get_ignorepkgs ();
+				var ignorepkgs_set = new GenericSet<string?> (str_hash, str_equal);
+				foreach (unowned string ignorepkg in ignorepkgs) {
+					ignorepkgs_set.add (ignorepkg);
+				}
 				foreach (unowned AlpmPackage pkg in pkgs) {
-					if (pkg.name in transaction.get_ignorepkgs ()) {
+					if (pkg.name in ignorepkgs_set) {
 						choose_ignorepkgs_dialog.pkgs_list.insert_with_values (null, -1, 0, true, 1, pkg.name);
+						ignorepkgs_set.remove (pkg.name);
 					} else {
 						choose_ignorepkgs_dialog.pkgs_list.insert_with_values (null, -1, 0, false, 1, pkg.name);
 					}
@@ -278,6 +285,11 @@ namespace Pamac {
 						}
 						return false;
 					});
+					// restore uninstalled ignorepkgs
+					foreach (unowned string ignorepkg in ignorepkgs_set) {
+						ignorepkg_string.append (" ");
+						ignorepkg_string.append (ignorepkg);
+					}
 					var new_alpm_conf = new HashTable<string,Variant> (str_hash, str_equal);
 					new_alpm_conf.insert ("IgnorePkg", new Variant.string (ignorepkg_string.str));
 					transaction.start_write_alpm_config (new_alpm_conf);
-- 
GitLab