I've taken a look through the Python script but with my limited knowledge I'm unable to workout how I would adapt this script to only function on the current document.
This may on the surface seem a superfluous question seeing as Editorial already has a current doc search function but there is a method to my madness as I'd like to adapt the script to be able to function as a more useful 'table of contents' workflow than the two that are currently available in the repository.
As useful as these are, neither functions in the same manner as 'Global Search'. The great thing about the global search function is that the search results sends you directly to an 'anchor' within the editor. If I could only work out how to limit the 'Global Search' workflow to the current doc, it would be fairly simple to adapt the workflow so that it presents a TOC in the preview but anchors back to the editor when you pick the header of your choice.
My inspiration here is the way that 'CMD + L' functions in FoldingText ('Go to Heading' function).