This is more or less a duplicate of TextMate.selected_files from textmate.rb. It is currently only used in a few places in the CVS, Mercurial, SVK and SVN bundles (sometimes via TextMate.selected_paths_for_shell).
However, there is one difference: If no files are selected, selected_path_array returns an array with a single entry for ENV["TM_FILEPATH"], or an empty array if this is not set. selected_files returns nil in those cases.
I wonder whether this functionality (“Give me an array of selected files, falling back to the current file if nothing is selected“) is so common that it should be part of the “official” bundle support API?
For example, the Git bundle has its own rather elaborate implementation that even supports different fallbacks (current file vs. project directory) and optional unique-filtering: https://github.com/textmate/git.tmbundle/blob/d1db42c2d71948662098183a6df519fb53a7a15b/Support/lib/git.rb#L114-L137
What do you think?
This is more or less a duplicate of
TextMate.selected_filesfromtextmate.rb. It is currently only used in a few places in the CVS, Mercurial, SVK and SVN bundles (sometimes viaTextMate.selected_paths_for_shell).However, there is one difference: If no files are selected,
selected_path_arrayreturns an array with a single entry forENV["TM_FILEPATH"], or an empty array if this is not set.selected_filesreturnsnilin those cases.I wonder whether this functionality (“Give me an array of selected files, falling back to the current file if nothing is selected“) is so common that it should be part of the “official” bundle support API?
For example, the Git bundle has its own rather elaborate implementation that even supports different fallbacks (current file vs. project directory) and optional unique-filtering: https://github.com/textmate/git.tmbundle/blob/d1db42c2d71948662098183a6df519fb53a7a15b/Support/lib/git.rb#L114-L137
What do you think?