Uncaught Error: Can't save destroyed buffer
- Press cmd+alt+e on a function
- Go to matching files
- Open a file via the brackets icon in the code-peek panel
- Close this file via tab bar
- Click save in code-peek panel
Atom: 1.17.0-beta5 x64 Electron: 1.3.15 OS: Mac OS X 10.12.4 Thrown From: code-peek package 1.4.18
Stack Trace
Uncaught Error: Can't save destroyed buffer
At /Applications/Atom Beta.app/Contents/Resources/app/node_modules/text-buffer/lib/text-buffer.js:1114
Error: Can't save destroyed buffer
at TextBuffer.module.exports.TextBuffer.saveAs (/Applications/Atom Beta.app/Contents/Resources/app/node_modules/text-buffer/lib/text-buffer.js:1114:1)
at TextBuffer.module.exports.TextBuffer.save (/Applications/Atom Beta.app/Contents/Resources/app/node_modules/text-buffer/lib/text-buffer.js:1108:1)
at TextEditor.module.exports.TextEditor.save (/Applications/Atom Beta.app/Contents/Resources/app/src/text-editor.js:925:1)
at CodePeekView.module.exports.CodePeekView.saveChanges (/packages/code-peek/lib/code-peek-view.coffee:187:27)
at Object.toggleCodePeekOff (/packages/code-peek/lib/code-peek.coffee:226:19)
at Function.module.exports.Emitter.simpleDispatch (/Applications/Atom Beta.app/Contents/Resources/app/node_modules/event-kit/lib/emitter.js:25:1)
at Emitter.module.exports.Emitter.emit (/Applications/Atom Beta.app/Contents/Resources/app/node_modules/event-kit/lib/emitter.js:141:1)
at /packages/code-peek/lib/code-peek-view.coffee:67:16)
at HTMLSpanElement.dispatch (/packages/atom-beautify/node_modules/jquery/dist/jquery.js:4435:9)
at HTMLSpanElement.elemData.handle (/packages/atom-beautify/node_modules/jquery/dist/jquery.js:4121:28)
Hmm, unable to reproduce this on 1.16. This only occurs when you have multiple matches, right?
Also, did you make any changes to the code in the code peek panel or in the main editor when you opened it in a new tab?
Oh ok. I'm on 1.17-beta5.
I've screen captured it for you ;)

I see. Thanks for taking the time to make the gif. I'm very confused why your actions.js file opens immediately in a new tab when you peek the function in MenuView.js. That shouldn't happen until you click the blue code icon... So maybe something else is going on.
I still can't reproduce it on 1.16. Unless I can, I'm going to punt on it until 1.17 is officially released. Sorry for the inconvenience,
I'm on version 1.4.21 and I have the same issue. In my installation, a matching file will open in a new tab as soon as it is selected in the code peek pane, even though I haven't clicked on the blue code icon. If I close the new tab and then click on the green check, save icon or the the blue code icon then I get the "Uncaught Error: Can't save destroyed buffer" error. My original question was just going to be, why does the matching file open in a new tab when I haven't clicked on the blue code icon. I think that is the root of the issue. I wonder if it is an issue with some other package I've installed. I'll try disabling them one at a time and see if that helps.
If anyone is still following this issue, I've found a hack to get around this issue, mostly. I doubt that this it the "right" way to fix it but works for me and maybe it will shed some light on the subject.
In code-peek.coffee, at the end of the toggleCodePeedOn function I added code to detach the text editor view and close the matching text editor.
toggleCodePeekOn: (matchingTextEditor) -> @codePeekView.attachTextEditorView(@location) @panel.show() @codePeekView.detachTextEditorView() closeEditor(matchingTextEditor)
`function closeEditor(matchingTextEditor) { var i = 0; var j = 0; var thisItem; var thisPane; var allPanes = atom.workspace.getPanes();
for (i=0; i<allPanes.length; i++) { thisPane = allPanes[i]; for (j=0; j<thisPane.items.length; j++) { thisItem = thisPane.items[j]; if (thisItem === matchingTextEditor) { thisPane.destroyItem(thisItem, true) } } } }`
I used plain JS because I don't know coffescript. :(
I lost the ability to save changes from the codepeek panel but that's alright with me because everything else is working. If I'm going to edit the file I'm going to open the full file (click on the blue code icon) and edit it there.