[geany/geany-plugins] aa55ff: Addons: Bookmarks: Prevent duplicating bookmarks when editing line
Enrico Tröger
git-noreply at geany.org
Sun Apr 10 09:22:14 UTC 2022
Branch: refs/heads/master
Author: Enrico Tröger <enrico.troeger at uvena.de>
Committer: Enrico Tröger <enrico.troeger at uvena.de>
Date: Sun, 29 Nov 2020 22:15:36 UTC
Commit: aa55ffa25bad1d772cef7d87d535a5f46cdec77b
https://github.com/geany/geany-plugins/commit/aa55ffa25bad1d772cef7d87d535a5f46cdec77b
Log Message:
-----------
Addons: Bookmarks: Prevent duplicating bookmarks when editing line
For some filetypes (more specifically some Scintilla lexers) it might
happen that an event with modificationType SC_MOD_CHANGEMARKER is
sent and so the current line is added as bookmark again.
To avoid this, check if the current line has already a bookmark and
update it in this case.
Might be related to #964.
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).
More information about the Plugins-Commits
mailing list