I've taken some time and hacked something together :-) This is JUST FOR DEMONSTRATION and clearly not meant as a pull request.
I've rewritten the `Next error` feature for demonstration purposes to resemble the feature I'm looking for. If you run this, you can move then cursor to a red line. And if you then activate `Next error` the compiler tab will show the error for the line you're currently in.
That's pretty much what I'm looking for. Except, that I like this routine to be executed automatically if the cursor is being moved to a red line.
<details> <summary>show code diff</summary>
Based on [commit fef873d](https://github.com/geany/geany/commit/fef873d485040bd3a679439802e5067ad9447d...).
``` diff --git a/src/msgwindow.c b/src/msgwindow.c index 350ec3880..2962c5df5 100644 --- a/src/msgwindow.c +++ b/src/msgwindow.c @@ -820,7 +820,10 @@ gboolean msgwin_goto_compiler_file_line(gboolean focus_editor) gint line; gchar *filename, *dir; GtkTreePath *path; - gboolean ret; + gboolean ret = FALSE; + GeanyDocument *doc = document_get_current(); + gint pos = sci_get_current_position(doc->editor->sci); + guint cur_line = sci_get_line_from_position(doc->editor->sci, pos) + 1;
path = gtk_tree_model_get_path(model, &iter); find_prev_build_dir(path, model, &dir); @@ -829,7 +832,8 @@ gboolean msgwin_goto_compiler_file_line(gboolean focus_editor) g_free(string); g_free(dir);
- ret = goto_compiler_file_line(filename, line, focus_editor); + if (line == cur_line) + ret = goto_compiler_file_line(filename, line, focus_editor); g_free(filename); return ret; } diff --git a/src/ui_utils.c b/src/ui_utils.c index 729feae94..50c6b221b 100644 --- a/src/ui_utils.c +++ b/src/ui_utils.c @@ -1777,15 +1777,10 @@ static gboolean tree_view_find(GtkTreeView *treeview, TVMatchCallback cb, gboole treesel = gtk_tree_view_get_selection(treeview); if (gtk_tree_selection_get_selected(treesel, &model, &iter)) { - /* get the next selected item */ - if (! tree_model_iter_get_next(model, &iter, down)) - return FALSE; /* no more items */ - } - else /* no selection */ - { - if (! gtk_tree_model_get_iter_first(model, &iter)) - return TRUE; /* no items */ + tree_model_iter_get_next(model, &iter, down); } + if (! gtk_tree_model_get_iter_first(model, &iter)) + return TRUE; /* no items */ while (TRUE) { gtk_tree_selection_select_iter(treesel, &iter); ```
</details>