It might be nicer if this used `Editor.posWithinRange`. Although that function has an inclusive end, but maybe the idea of using `Editor.indexFromPos` to check if pos is inside popover might make it look a lot simpler.