Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught TypeError: savePath.lastIndexOf is not a function #54

Open
TakeshiHoshina opened this issue Oct 18, 2020 · 5 comments
Open

Uncaught TypeError: savePath.lastIndexOf is not a function #54

TakeshiHoshina opened this issue Oct 18, 2020 · 5 comments

Comments

@TakeshiHoshina
Copy link

[Enter steps to reproduce:]

  1. ...
  2. ...

Atom: 1.52.0 x64
Electron: 6.1.12
OS: Mac OS X 10.15.5
Thrown From: plantuml-viewer package 0.7.2

Stack Trace

Uncaught TypeError: savePath.lastIndexOf is not a function

At /Users/takeshihoshina1/.atom/packages/plantuml-viewer/lib/plantuml-viewer-view.js:189

TypeError: savePath.lastIndexOf is not a function
    at saveAs (/packages/plantuml-viewer/lib/plantuml-viewer-view.js:189:48)
    at /packages/plantuml-viewer/lib/plantuml-viewer-view.js:103:7)
    at CommandRegistry.handleCommandEvent (/Applications/Atom.app/Contents/Resources/app/static/<embedded>:11:349963)
    at KeymapManager.dispatchCommandEvent (/Applications/Atom.app/Contents/Resources/app/static/<embedded>:11:1231297)
    at KeymapManager.handleKeyboardEvent (/Applications/Atom.app/Contents/Resources/app/static/<embedded>:11:1227431)
    at WindowEventHandler.handleDocumentKeyEvent (/Applications/Atom.app/Contents/Resources/app/static/<embedded>:11:284820)

Commands

     -2:46.2.0 core:backspace (input.hidden-input)
     -1:56.3.0 plantuml-preview:toggle (input.hidden-input)
  3x -1:37.7.0 platformio-ide-terminal:paste (div.terminal)
     -0:59.1.0 core:save (div.plantuml-viewer.native-key-bindings)

Non-Core Packages

atom-beautify 0.33.4 
file-icons 2.1.43 
highlight-selected 0.17.0 
language-plantuml 0.2.0 
pigments 0.40.6 
plantuml-preview 0.12.10 
plantuml-viewer 0.7.2 
platformio-ide-terminal 2.10.0 
project-manager 3.3.8 
@xanadiu
Copy link

xanadiu commented Nov 10, 2020

(I encountered this error, too)

Steps to reproduce:

  1. Toggle the Plantuml Viewer in Atom
  2. Focus the Plantuml Viewer
  3. Try to save the image
  4. The error occurs while the dialogue for the save location appears; saving is not possible

Atom: 1.52.0 x64
OS: macOS 10.15.7

@nguyenquangson
Copy link

I also like your error.
You can fix that by following steps.
C:\Users\XXXX.atom\packages\plantuml-viewer\lib\plantuml-viewer-view.js

function saveAs () {

async function saveAs () {

var savePath = atom.showSaveDialogSync(options)

const savePath = await atom.showSaveDialogSync(options)

last replare using savePath -> savePath.filePath

@JerilynZ
Copy link

I also like your error.
You can fix that by following steps.
C:\Users\XXXX.atom\packages\plantuml-viewer\lib\plantuml-viewer-view.js

function saveAs () {

async function saveAs () {

var savePath = atom.showSaveDialogSync(options)

const savePath = await atom.showSaveDialogSync(options)

last replare using savePath -> savePath.filePath

thank you for your share. It is useful. ③ should be: last, please replace "savePath" with "savePath.filePath", beside the "const savePath = await atom.showSaveDialogSync(options)"

@triynko
Copy link

triynko commented Jan 19, 2021

Same error encountered. Jan 2021.

@Pyponou
Copy link

Pyponou commented Jun 2, 2021

Same issue

Here is the fix made by @nguyenquangson , I put it here as I didn't understand the number 3 :

  async function saveAs () {
    var filters = [
      { name: 'Encapsulated PostScript (.eps)', extensions: ['eps'] },
      { name: 'Scalable Vector Graphics (.svg)', extensions: ['svg'] },
      { name: 'Portable Network Graphics (.png)', extensions: ['png'] }
    ]
    var filePath = editor.getPath().replace(/\.[^/.]+$/, '')
    var options = { defaultPath: filePath, filters: filters }
    const savePath = await atom.showSaveDialogSync(options)

    if (savePath.filePath) {
      var extension = savePath.filePath.substr(savePath.filePath.lastIndexOf('.') + 1)
      var fileStream = fs.createWriteStream(savePath.filePath)

      var plantumlOptions = {
        format: extension,
        include: includePath,
        dot: atom.config.get('plantuml-viewer.graphvizDotExecutable') || getDetectedPathFor('dot'),
        config: atom.config.get('plantuml-viewer.configFile'),
        charset: atom.config.get('plantuml-viewer.charset')
      }

      var gen = plantuml.generate(editor.getText(), plantumlOptions)
      gen.out.pipe(fileStream)
    }
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants