patch 8.1.1928: popup windows don't move with the text when making changes
Problem: Popup windows don't move with the text when making changes.
Solution: Add the 'textprop" property to the popup window options, position
the popup relative to a text property. (closes #4560)
No tests yet.
diff --git a/src/textprop.c b/src/textprop.c
index 93787f3..7947d34 100644
--- a/src/textprop.c
+++ b/src/textprop.c
@@ -91,6 +91,20 @@
}
/*
+ * Get the prop type ID of "name".
+ * When not found return zero.
+ */
+ int
+find_prop_type_id(char_u *name, buf_T *buf)
+{
+ proptype_T *pt = find_prop(name, buf);
+
+ if (pt == NULL)
+ return 0;
+ return pt->pt_id;
+}
+
+/*
* Lookup a property type by name. First in "buf" and when not found in the
* global types.
* When not found gives an error message and returns NULL.
@@ -368,6 +382,40 @@
}
/*
+ * Find text property "type_id" in the visible lines of window "wp".
+ * Match "id" when it is > 0.
+ * Returns FAIL when not found.
+ */
+ int
+find_visible_prop(win_T *wp, int type_id, int id, textprop_T *prop,
+ linenr_T *found_lnum)
+{
+ linenr_T lnum;
+ char_u *props;
+ int count;
+ int i;
+
+ // w_botline may not have been updated yet.
+ if (wp->w_botline > wp->w_buffer->b_ml.ml_line_count)
+ wp->w_botline = wp->w_buffer->b_ml.ml_line_count + 1;
+ for (lnum = wp->w_topline; lnum < wp->w_botline; ++lnum)
+ {
+ count = get_text_props(wp->w_buffer, lnum, &props, FALSE);
+ for (i = 0; i < count; ++i)
+ {
+ mch_memmove(prop, props + i * sizeof(textprop_T),
+ sizeof(textprop_T));
+ if (prop->tp_type == type_id && (id <= 0 || prop->tp_id == id))
+ {
+ *found_lnum = lnum;
+ return OK;
+ }
+ }
+ }
+ return FAIL;
+}
+
+/*
* Set the text properties for line "lnum" to "props" with length "len".
* If "len" is zero text properties are removed, "props" is not used.
* Any existing text properties are dropped.