@techee requested changes on this pull request.

@dolik-rce Thanks! I was hesitating whether this patch doesn't complicate things but it's not too bad so let's do that!

There are some minor comments in the review, nothing major, mostly some renames and minor cleanups.


In projectorganizer/src/prjorg-project.c:

> @@ -532,6 +571,7 @@ void prjorg_project_open(GKeyFile * key_file)
 	generate_tag_prefs = utils_get_setting_integer(key_file, "prjorg", "generate_tag_prefs", PrjOrgTagAuto);
 	show_empty_dirs = utils_get_setting_boolean(key_file, "prjorg", "show_empty_dirs", TRUE);
 
+	open_files = get_session_files(key_file);

Big fat comment here what we are actually doing and why.


In projectorganizer/src/prjorg-project.c:

> @@ -343,6 +345,7 @@ static void update_project(
 	gchar **header_patterns,
 	gchar **ignored_dirs_patterns,
 	gchar **ignored_file_patterns,
+	gchar **open_files,

session_files


In projectorganizer/src/prjorg-project.c:

>  static void regenerate_tags(PrjOrgRoot *root, gpointer user_data)
 {
 	GHashTableIter iter;
 	gpointer key, value;
 	GPtrArray *source_files;
 	GHashTable *file_table;
+	gchar **open_files;

I'd suggest renaming it to session_files because these aren't open yet and may be confusing.


In projectorganizer/src/prjorg-project.c:

> @@ -292,10 +293,11 @@ static void regenerate_tags(PrjOrgRoot *root, gpointer user_data)
 		gchar *utf8_path = key;
 		gchar *locale_path = utils_get_locale_from_utf8(utf8_path);
 		gchar *basename = g_path_get_basename(locale_path);
+		gboolean is_open = open_files && g_strv_contains(open_files, utf8_path);

Maybe call it will_open.


In projectorganizer/src/prjorg-project.c:

> @@ -310,7 +312,7 @@ static void regenerate_tags(PrjOrgRoot *root, gpointer user_data)
 }
 
 
-void prjorg_project_rescan(void)
+void prjorg_project_rescan(gchar **open_files)

Rename to session_files


In projectorganizer/src/prjorg-project.c:

>  void prjorg_project_open(GKeyFile * key_file)
 {
 	gchar **source_patterns, **header_patterns, **ignored_dirs_patterns, **ignored_file_patterns, **external_dirs, **dir_ptr, *last_name;
 	gint generate_tag_prefs;
 	gboolean show_empty_dirs;
 	GSList *elem = NULL, *ext_list = NULL;
 	gchar *utf8_base_path;
+	GPtrArray *open_files;

session_files


In projectorganizer/src/prjorg-project.c:

> @@ -275,14 +275,15 @@ static GeanyFiletype *filetypes_detect(const gchar *utf8_filename)
 	return ft;
 }
 
-

keep two empty lines before functions


In projectorganizer/src/prjorg-project.c:

> +		tmp_array = g_key_file_get_string_list(config, "files", entry, NULL, &error);
+		if (! tmp_array || error)
+		{
+			g_error_free(error);
+			error = NULL;
+			have_session_files = FALSE;
+		} else {
+			unescaped_filename = g_uri_unescape_string(tmp_array[7], NULL);
+			g_ptr_array_add(files, g_strdup(unescaped_filename));
+			g_free(unescaped_filename);
+		}
+		i++;
+	}
+	g_ptr_array_add(files, NULL);
+
+	return files;

change to return g_ptr_array_free(files, FALSE); and return gchar ** from the function.


In projectorganizer/src/prjorg-project.c:

> @@ -563,6 +604,7 @@ void prjorg_project_open(GKeyFile * key_file)
 	g_strfreev(ignored_dirs_patterns);
 	g_strfreev(ignored_file_patterns);
 	g_strfreev(external_dirs);
+	g_ptr_array_free(open_files, TRUE);

Use g_strfreev with the other changes above.


In projectorganizer/src/prjorg-project.c:

> @@ -292,10 +293,11 @@ static void regenerate_tags(PrjOrgRoot *root, gpointer user_data)
 		gchar *utf8_path = key;
 		gchar *locale_path = utils_get_locale_from_utf8(utf8_path);
 		gchar *basename = g_path_get_basename(locale_path);
+		gboolean is_open = open_files && g_strv_contains(open_files, utf8_path);

Cast open_files to (const gchar **) to avoid warnings.


In projectorganizer/src/prjorg-project.c:

> @@ -310,7 +312,7 @@ static void regenerate_tags(PrjOrgRoot *root, gpointer user_data)
 }
 
 
-void prjorg_project_rescan(void)
+void prjorg_project_rescan(gchar **open_files)

In addition, I'd suggest converting it to a static function called rescan_project and having a separate prjorg_project_rescan() without any arguments and just calling rescan_project(NULL); inside it. This way you avoid the diffs adding the NULL parameter across the project.


In projectorganizer/src/prjorg-project.c:

>  void prjorg_project_open(GKeyFile * key_file)
 {
 	gchar **source_patterns, **header_patterns, **ignored_dirs_patterns, **ignored_file_patterns, **external_dirs, **dir_ptr, *last_name;
 	gint generate_tag_prefs;
 	gboolean show_empty_dirs;
 	GSList *elem = NULL, *ext_list = NULL;
 	gchar *utf8_base_path;
+	GPtrArray *open_files;

In addition, with the suggested change in get_session_files, change to gchar **.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <geany/geany-plugins/pull/1290/review/1729344039@github.com>