-
Notifications
You must be signed in to change notification settings - Fork 43
Description
Problem description
Instances of HTMLSheet don't have a property that allows you to distinguish them from other HTMLSheet instances except for the sheet's id.
This makes finding and reusing an existing sheet problematic; if you lose the reference to the original instance returned by window.new_html_sheet() the only thing you can rely on is the id, but because the sheet id changes across sessions it's not possible in a general sense to be sure you're selecting the correct instance if there is more than one.
In contrast, an ImageSheet responds to file_name() to tell you the filename of the image, and TextSheet instances report their view, from which you can determine the required information.
Preferred solution
If the underlying Sheet class had set_name() and name() methods natively, it would be possible to distinguish and work with sheets in a safer manner; this would be an extension to the existing logic already in place:
TextSheetwraps aView, andViewhasset_name()andname(), so it could defer these methods directly to it'sviewwith the current logic.ImageSheetwraps an image and is not generally modifiable via the API. Aname()method would allow you to open an image and alter it's display name in the tab;get_name()could report thefile_name()if no custom name was set.HtmlSheethas aset_name()method, but no correspondingname()method, which seems like an oversight.
Alternatives
None that I can think of, except having HTMLSheet instances that are restored from session information keep the same sheet ID they originally had (or maybe do that generically for all restored sheets), but this seems problematic and probably not a good idea.