         window.smc.editors ?= {}
         window.smc.editors[filename] = editor
 
+        editor.init_autosave()
         return editor
 
     create_opened_file_tab: (filename) =>

class FileEditorWrapper extends FileEditor
    constructor: (@editor, @filename, @content, @opts) ->
        @init_wrapped(@editor, @filename, @content, @opts)
        @init_autosave()

    init_wrapped: () =>
        # Define @element and @wrapped in derived class
        throw Error('must define in derived class')

    save: () =>
        @wrapped?.save?()

    has_unsaved_changes: (val) =>
        return @wrapped?.has_unsaved_changes?(val)


        if tab.editor_open()
            # Disconnect from remote session (if relevant), clean up, etc.
            e = tab.editor()
            e.save?()
            e.disconnect_from_session?()
            e.remove?()

        tab.link.remove()
        tab.close_tab?()
