Branch: refs/heads/master Author: Enrico Tröger enrico.troeger@uvena.de Committer: GitHub noreply@github.com Date: Sun, 10 Apr 2022 09:22:11 UTC Commit: 097644f3bf39316190302387f19b04e1f5e74b10 https://github.com/geany/geany-plugins/commit/097644f3bf39316190302387f19b04...
Log Message: ----------- Merge pull request #1040 from eht16/fix_addons_bookmark_duplicating
Addons: Bookmarks: Prevent duplicating bookmarks when editing line
Modified Paths: -------------- addons/src/ao_bookmarklist.c
Modified: addons/src/ao_bookmarklist.c 26 lines changed, 21 insertions(+), 5 deletions(-) =================================================================== @@ -190,11 +190,27 @@ static void add_line(AoBookmarkList *bm, ScintillaObject *sci, gint line_nr) line = g_strdup(_("(Empty Line)")); tooltip = g_markup_escape_text(line, -1);
- gtk_list_store_insert_with_values(priv->store, NULL, -1, - BMLIST_COL_LINE, line_nr + 1, - BMLIST_COL_NAME, line, - BMLIST_COL_TOOLTIP, tooltip, - -1); + /* search for existing bookmark on current line */ + priv->search_line = line_nr + 1; + priv->search_iter = NULL; + gtk_tree_model_foreach(GTK_TREE_MODEL(priv->store), tree_model_foreach, bm); + if (priv->search_iter != NULL) + { /* update existing bookmark with current line content */ + gtk_list_store_set(priv->store, priv->search_iter, + BMLIST_COL_LINE, line_nr + 1, + BMLIST_COL_NAME, line, + BMLIST_COL_TOOLTIP, tooltip, + -1); + gtk_tree_iter_free(priv->search_iter); + } + else + { /* add bookmark */ + gtk_list_store_insert_with_values(priv->store, NULL, -1, + BMLIST_COL_LINE, line_nr + 1, + BMLIST_COL_NAME, line, + BMLIST_COL_TOOLTIP, tooltip, + -1); + } g_free(line); g_free(tooltip); }
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).