manastech / atom-crystal-tools

Atom package that integrates crystal tools
https://atom.io/packages/crystal-tools
MIT License
10 stars 1 forks source link

Uncaught Error: Can't save buffer with no file path #2

Open lbguilherme opened 9 years ago

lbguilherme commented 9 years ago
  1. Start writing a crystal file
  2. Do not save it
  3. Hit Ctrl+Alt+C for Crystal Context

Solution would likely be to create a temp file.

Atom Version: 1.0.11 System: "Fedora release Thrown From: crystal-tools package, v0.3.0

Stack Trace

Uncaught Error: Can't save buffer with no file path

At /usr/share/atom/resources/app.asar/node_modules/text-buffer/lib/text-buffer.js:1011

Error: Can't save buffer with no file path
  at TextBuffer.module.exports.TextBuffer.saveAs (/usr/share/atom/resources/app.asar/node_modules/text-buffer/lib/text-buffer.js:1011:15)
  at TextBuffer.module.exports.TextBuffer.save (/usr/share/atom/resources/app.asar/node_modules/text-buffer/lib/text-buffer.js:1005:19)
  at TextEditor.module.exports.TextEditor.save (/usr/share/atom/resources/app.asar/src/text-editor.js:584:26)
  at Object.module.exports.CrystalTools._cursorCommand (/home/guilherme/.atom/packages/crystal-tools/lib/crystal-tools.coffee:88:14)
  at Object.module.exports.CrystalTools.context (/home/guilherme/.atom/packages/crystal-tools/lib/crystal-tools.coffee:128:6)
  at atom-workspace.subscriptions.add.atom.commands.add.crystal-tools:context (/home/guilherme/.atom/packages/crystal-tools/lib/crystal-tools.coffee:46:89)
  at CommandRegistry.module.exports.CommandRegistry.handleCommandEvent (/usr/share/atom/resources/app.asar/src/command-registry.js:245:29)
  at /usr/share/atom/resources/app.asar/src/command-registry.js:3:61
  at KeymapManager.module.exports.KeymapManager.dispatchCommandEvent (/usr/share/atom/resources/app.asar/node_modules/atom-keymap/lib/keymap-manager.js:524:16)
  at KeymapManager.module.exports.KeymapManager.handleKeyboardEvent (/usr/share/atom/resources/app.asar/node_modules/atom-keymap/lib/keymap-manager.js:347:22)
  at HTMLDocument.module.exports.WindowEventHandler.onKeydown (/usr/share/atom/resources/app.asar/src/window-event-handler.js:184:20)

Commands

     -1:08.5.0 core:move-up (atom-text-editor.editor.is-focused)
     -1:08.3.0 editor:move-to-end-of-screen-line (atom-text-editor.editor.is-focused)
  3x -1:08.1.0 editor:newline (atom-text-editor.editor.is-focused)
  2x -1:01.7.0 core:backspace (atom-text-editor.editor.is-focused)
     -1:00.5.0 core:move-up (atom-text-editor.editor.is-focused)
     -1:00.1.0 editor:move-to-end-of-screen-line (atom-text-editor.editor.is-focused)
     -0:59.8.0 core:backspace (atom-text-editor.editor.is-focused)
     -0:57.7.0 editor:newline (atom-text-editor.editor.is-focused)
     -0:50 core:backspace (atom-text-editor.editor.is-focused)
     -0:46.6.0 core:move-left (atom-text-editor.editor.is-focused)
  2x -0:45.6.0 core:move-down (atom-text-editor.editor.is-focused)
  5x -0:44.9.0 editor:newline (atom-text-editor.editor.is-focused)
     -0:34.9.0 crystal-tools:context (atom-text-editor.editor.is-focused)
     -0:14.2.0 core:save (atom-text-editor.editor.is-focused)
     -0:06.6.0 editor:copy-path (atom-text-editor.editor.is-focused)
     -0:00.5.0 crystal-tools:context (atom-text-editor.editor.is-focused)

Config

{
  "core": {},
  "crystal-tools": {}
}

Installed Packages

# User
crystal-tools, v0.3.0
language-crystal-actual, v0.28.1
linter, v1.5.0
linter-crystal, v3.1.0

# Dev
No dev packages
bcardiff commented 9 years ago

Good catch. Probably a tempfile or If I can send the whole thing to crystal eval it might work. This is only valid if the editor has no filename associated (and then is not inside a project). You won't be able to require anything outside crystal std but for small examples seems right.