@techee requested changes on this pull request.
Looks good and works well (apart from the two nitpicky style comments).
> the core issue with keeping right tab active after opening non-existent file
> from console is related to fact that we cannot manually activate tab that
> does not yet have underlying file saved to disk
Right, that's the reason.
One more thing though - when playing with it, I didn't quite like the behavior
of "close all" documents which also closes the temp files - I think these
should stay open as they are not normal files (I typically use "close all" when
the number of open files gets out of my control but closing temp files kind of
kills this feature because one would have to open them manually and spend time
on something that should happen automatically).
I believe this could be achieved by reopening all temp files when the number of
open tabs drops to 0. I think one could schedule an idle function inside
`persistent_temp_files_document_close_cb()` (in the
`geany_is_closing_all_documents()` case) and inside this idle function do
something like
```C
static gboolean persistent_temp_files_document_close_idle(gpointer data)
{
if (gtk_notebook_get_n_pages(GTK_NOTEBOOK(geany->main_widgets->notebook))
== 0)
load_all_temp_files_into_editor();
}
```
I think at the point this idle function is called, Geany will have all the
documents closed.
(One slight problem is that when closing 100 files, the idle function will be
scheduled 100 times and when there are no temp files,
`load_all_temp_files_into_editor();` will be also called 100 times and try to
find some temp files but I think even this will be very quick and not worth
taking care of.)
> if (is_temp_saved_file_name(filename))
{
- GeanyDocument *doc =
document_open_file(locale_file_path, FALSE, NULL, NULL);
+ gchar *locale_file_path, *file_path_utf8;
+
+ locale_file_path = g_build_path(G_DIR_SEPARATOR_S,
persistent_temp_files_target_dir, filename, NULL);
+ file_path_utf8 =
utils_get_utf8_from_locale(locale_file_path);
+ GeanyDocument *doc =
document_find_by_filename(file_path_utf8);
Move `GeanyDocument *doc;` declaration to the beginning of the block.
> if (is_temp_saved_file_name(filename))
{
- GeanyDocument *doc =
document_open_file(locale_file_path, FALSE, NULL, NULL);
+ gchar *locale_file_path, *file_path_utf8;
+
+ locale_file_path = g_build_path(G_DIR_SEPARATOR_S,
persistent_temp_files_target_dir, filename, NULL);
+ file_path_utf8 =
utils_get_utf8_from_locale(locale_file_path);
+ GeanyDocument *doc =
document_find_by_filename(file_path_utf8);
+
+ g_free(file_path_utf8);
+
+ if (doc == NULL) {
Drop `{}` (or move `{` to the next line).
--
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/3911#pullrequestreview-2224871993
You are receiving this because you are subscribed to this thread.
Message ID: <geany/geany/pull/3911/review/[email protected]>