@techee requested changes on this pull request.

Looks good except for the minor comments below.

I was actually thinking about not doing this at all because it doesn't cover 
all fold/unfold situations like e.g. using Geany's keybindings for folding but 
the patch is simple and better than nothing so let's do it.

Would you post this as a separate pull request? If 
https://github.com/geany/geany-plugins/pull/1338 looks good to you, I'd merge 
that PR after which this one could be merged.

> +
+
+void ensure_current_line_expanded(ScintillaObject *sci)
+{
+       gint line = GET_CUR_LINE(sci);
+       if (!SSM(sci, SCI_GETLINEVISIBLE, line, 0))
+               SSM(sci, SCI_ENSUREVISIBLE, line, 0);
+}
+
+
+gint jump_to_expended_parent(ScintillaObject *sci, gint line)
+{
+       gint fold_parent = line;
+
+       /* go through the parents as long as they are not visible */
+       while (SSM(sci, SCI_GETLINEVISIBLE, fold_parent, 0) == FALSE) {

Better `!SSM(...)` instead of the `FALSE` comparison.

Also place `{` on separate line to match the other code style.

> +{
+       gint line = GET_CUR_LINE(sci);
+       if (!SSM(sci, SCI_GETLINEVISIBLE, line, 0))
+               SSM(sci, SCI_ENSUREVISIBLE, line, 0);
+}
+
+
+gint jump_to_expended_parent(ScintillaObject *sci, gint line)
+{
+       gint fold_parent = line;
+
+       /* go through the parents as long as they are not visible */
+       while (SSM(sci, SCI_GETLINEVISIBLE, fold_parent, 0) == FALSE) {
+               gint prev_parent = SSM(sci, SCI_GETFOLDPARENT, fold_parent, 0);
+
+               if (prev_parent == -1) break;

`break` on separate line.

> +{
+       gint fold_parent = line;
+
+       /* go through the parents as long as they are not visible */
+       while (SSM(sci, SCI_GETLINEVISIBLE, fold_parent, 0) == FALSE) {
+               gint prev_parent = SSM(sci, SCI_GETFOLDPARENT, fold_parent, 0);
+
+               if (prev_parent == -1) break;
+               fold_parent = prev_parent;
+       }
+
+       if (fold_parent != line)
+       {
+               /* move the cursor on the visible line before the fold */
+               gint pos = SSM(sci, SCI_POSITIONFROMLINE, fold_parent, 0);
+               SET_POS(sci, pos, TRUE);

Use `SET_POS_NOX()` instead. This one will preserve the "maximum x" cursor 
value so when further moving up or down, this one will be recovered.

> @@ -32,5 +32,8 @@ void perform_substitute(ScintillaObject *sci, const gchar 
> *cmd, gint from, gint
        const gchar *flag_override);
 
 gint get_line_number_rel(ScintillaObject *sci, gint shift);
+void ensure_current_line_expanded(ScintillaObject *sci);

Again, remove, it's from another patch.

> @@ -306,6 +306,14 @@ gboolean vi_notify_sci(SCNotification *nt)
                }
        }
 
+       if (nt->nmhdr.code == SCN_MARGINCLICK) {

`{` on separate line.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany-plugins/pull/1326#pullrequestreview-2045634798
You are receiving this because you are subscribed to this thread.

Message ID: <geany/geany-plugins/pull/1326/review/2045634...@github.com>

Reply via email to