How about the attached change fixing it at a slightly lower level instead?

I see you updated the docstring as well. The new paragraph you added is a little unclear, it seems to imply that which only works for function files (m-files), but it also works with arbitrary files of any type, as well as built-in functions and functions in oct-files.