Not sure this has not yet be done (sorry if yes), but this little script allows to close an open tab.
import editor
from objc_util import *
@on_main_thread
def closeTab(file_name):
win = UIApplication.sharedApplication().keyWindow()
root_vc = win.rootViewController()
tabs_vc = root_vc.detailViewController()
for tab in tabs_vc.tabViewControllers():
if tab.isKindOfClass_(ObjCClass('PA2UniversalTextEditorViewController')):
#print(str(tab.filePath()))
tab_file = str(tab.filePath())
if tab_file == editor.get_path():
# crash if try to close edited file
continue
if file_name in tab_file:
tabs_vc.closeTab_(tab)
return True
return False
print(closeTab('xxxxxx'))