The following code does not do what I would expect:
(with-current-buffer (get-buffer-create "*Test*")
(erase-buffer)
(insert " ")
(insert-text-button "Button1"
'foo 'bar)
(insert " ")
(insert-text-button "Button2"
'foo 'bar)
(beginning-of-buffer)
(text-property-search-forward 'foo 'bar nil t)
(display-buffer (current-buffer)))
I would expect the point to land on the first button. However, it lands on the second.