[Scripting] Close Tab on empty "Go BACK" history list


I usually have some of my "always open" folder in locked tabs (e.g. my downloads folder), and as I open subfolders in them a new tab is spawned, and I usually browse around deeper inside the subfolders, sorting files etc. What I'd like is to have this newly spawned tab autoclose as I try to browse backwards once "too many" times, i.e. when the history reaches "NULL". (Some of these "always open" folders are network drives so I don't want to use the "allow folder changes" option for the locked tabs, to avoid re-reading them.)

At first I thought about an OnClick script that checks the history list of the tab and executes a "Go TABCLOSE" instead of a "Go BACK" when the history list is empty, but it doesn't seem that the history list is available to query from a script. Is that correct or am I just bad at searching the help files? :slight_smile:

If that's correct, I guess my only choice is setting up an OnAfterFolderChange to trigger a tabclose on certain conditions, but it seems a bit overkill to have that script check this on every single FolderChange event when it'll be an unnecessary check 99% of the time. Any other tips on how to set this up, or is the overhead of running that script so minimal that it doesn't really matter..?

(Maybe this function is already available built-in somehow, because I think I've seen it somewhere as a[n advanced] setting or something in the past. Like "close tab when back history reaches zero" or something, but I couldn't find it anywhere now and didn't find anything in the forums as well.)

Any input on this is helpful before I take the plunge or setting it up :slight_smile:

If I open an empty tab and load a path, the "Back" button is unavailable, so it looks like you cannot go back once "too many"? o)
There will be no OnAfter/BeforeFolderChange event and a general tab history is not available to scripts, so it seems impossible - for Go BACK at least.

Things look different for Go UP, once a real path is opened in a tab (not empty anymore), you can save that initial path to the tab and whenever the path is changed, check against that initial path if you are above/outside of it to close the tab. Normally, folderchange events should not lead to noticeable delays, unless they do some time consuming things.

Thanks tbone!

I haven't delved deeper into the OnAfter/BeforeFolderChange yet, but that seems logical. I just assumed the FolderChange was initiated on all attempts to browse, and spat out a "fail" when it couldn't go back, but maybe the "Go BACK" command is locked down if there isn't a history.

Either way, I'll look into it later unless there are any more input on this from the community, and setting a "if Go UP reaches this path, close the tab" seems like a viable option. Thanks again! :slight_smile: