without a new tab


So from the API, opens the file specified by the uri, and a returns a Promise that resolves to a TextEditor instance. But what I’m seeing is that in addition to returning the Promise, it automatically opens up a new pane with the opened file. So I’ve tried the following:

that = @
.then (editor) ->
    @MyViewWithEditor = new MyViewWithEditor(state.MMyViewWithEditorState, editor)
    that.panel = atom.workspace.addBottomPanel(item: @MyViewWithEditor.getElement(), visible: false)

Which copies the text editor opened in the new tab to my new panel. But it still leaves a new tab-looking thing open, which when closed, also deletes the editor in my new panel:

Which has lead me to the following fix:

that = @
.then (editor) ->
    new_editor = editor.copy() #copy the editor
    @MyViewWithEditor = new MyViewWithEditor(state.MMyViewWithEditorState, new_editor)
    that.panel = atom.workspace.addBottomPanel(item: @MyViewWithEditor.getElement(), visible: false)

Which leaves the editor in tact when closed, but gives me the following error when I try to type in the editor:

Uncaught TypeError: Cannot read property 'displayBuffer' of undefined

This lead me to believe that when closing the original editor, it deletes the reference to the display buffer, but sure enough in the text-editor code, it does indeed make a new copy.

copy: ->
    displayBuffer = @displayBuffer.copy()

Which I’ve also verified with the debugger.
So anyways, my question is: Does anyone know why this error would be showing up and how to fix it OR a simpler way to create a lone text buffer in a new panel?

[EDIT] It seems as though it might be coming from autocomplete:

TypeError: Cannot read property 'displayBuffer' of undefined
  at SymbolStore.module.exports.SymbolStore.getTokenizedLines (/Applications/
  at SymbolStore.module.exports.SymbolStore.operateOnTokensInBufferRange (/Applications/
  at SymbolStore.module.exports.SymbolStore.removeTokensInBufferRange (/Applications/
  at /Applications/
  at Emitter.module.exports.Emitter.emit (/Applications/
  at TextBuffer.module.exports.TextBuffer.applyChange (/Applications/
  at TextBuffer.module.exports.TextBuffer.setTextInRange (/Applications/
  at Selection.module.exports.Selection.insertText (/Applications/
  at /Applications/
  at /Applications/
  at TextBuffer.module.exports.TextBuffer.transact (/Applications/
  at TextEditor.module.exports.TextEditor.transact (/Applications/
  at /Applications/
  at TextEditor.module.exports.TextEditor.mergeSelections (/Applications/
  at TextEditor.module.exports.TextEditor.mergeIntersectingSelections (/Applications/
  at TextEditor.module.exports.TextEditor.mutateSelectedText (/Applications/
  at TextEditor.module.exports.TextEditor.insertText (/Applications/
  at TextEditorComponent.module.exports.TextEditorComponent.onTextInput (/Applications/
  at HTMLDivElement.__bind (/Applications/


To create a new text editor, you can use

var textEditorView = document.createElement('atom-text-editor');
atom.workspace.addBottomPanel({item: myPanel});

To set text, do

var textEditorModel = textEditorView.getModel();

or maybe even


Though I don’t really know if that also loads a file etc. :wink:

PS you might find it useful to know about fat arrows in CoffeeScript. They allow you to replace

that = @
do ->


do =>

Notice the => instead of ->


Huge thanks for the PS!