@b4n approved this pull request.
Not tested, but LGTM
/* we need to re-convert iter->filter_iter as the original filter_iter
+ * becomes invalid after removal and re-addition of doc from/to sidebar */
The root reason is that iter itself changed (which might not be clear here, as it's a pointer to a member of `doc`, and is not directly modified here), so incidentally the filtered one does at well.
have_filter_iter = gtk_tree_model_filter_convert_child_iter_to_iter(
+ GTK_TREE_MODEL_FILTER(filter_model), &filter_iter, iter); + if (have_filter_iter) + gtk_tree_selection_select_iter(treesel, &filter_iter);
Style-wise, I'd drop the `have_filter_iter` variable and move the call in the `if()`, but if that was chosen because the call is long, fair enough.