The ways on how a "folder name string" should be created and compared is divided in many parts of `get_doc_parent()` and the functions it call. One is from `get_folder_name()` itself, another is from `find_tree_iter_dir()` (`if (utils_str_equal(dir, ".")) dir = GEANY_STRING_UNTITLED;`), and another in the assignment of the item to `store_openfiles` (`DOCUMENTS_SHORTNAME, doc->file_name ? dirname : GEANY_STRING_UNTITLED`).
The ambiguity causes issues like having multiple parents in the Documents list that has the name `.` when the filename has a basename but not a directory name. This can be done by creating multiple new files with a template.
This patch is basically an overhaul to fix the ambiguity, and the issue is fixed along with it. If `get_folder_name()` is shared and used somewhere else besides `sidebar.c`, it would no longer require a wrapper just to make the returned string consistent. You can view, comment on, or merge this pull request online at:
https://github.com/geany/geany/pull/1199
-- Commit Summary --
* Fix new files created with template not being placed in 'untitled' folder * Place everything about creating document folder string in get_doc_folder()
-- File Changes --
M src/sidebar.c (128)
-- Patch Links --
https://github.com/geany/geany/pull/1199.patch https://github.com/geany/geany/pull/1199.diff