Komodo / KomodoEdit

Komodo Edit is a fast and free multi-language code editor. Written in JS, Python, C++ and based on the Mozilla platform.
http://www.komodoide.com/komodo-edit
Other
2.14k stars 299 forks source link

Don't Correct Work JS Beautify #3827

Closed Nemial closed 4 years ago

Nemial commented 4 years ago

Platform Information

Komodo IDE Komodo Version 12.0.0

The standard JS Beautify formatter does not work correctly. It does not recognize JavaScript arrow functions, function = () => {} and corrects them to function = () = > {}, which naturally causes the function to fail.

th3coop commented 4 years ago

@Nemial your best bet will be to a new formatter in your preferences:

Nemial commented 4 years ago

I tried to do this, but js-beautify doesn't work with standard options,but only in the style where changes are visible when reloading files in the IDE. And alas, I could not overcome it in any way.

js-beautify -o file.js doesn't work if you do everything according to your advice

th3coop commented 4 years ago

@Nemial could you share a screenshot of your config? I'm not clear what issue you're having.

Nemial commented 4 years ago

Снимок экрана_2020-01-23_14-14-28

th3coop commented 4 years ago

That field is expecting an executable file which a JS file is not. Isn't there a binary/executable file that gets installed?

Nemial commented 4 years ago

There will be no difference if I put a file from the/usr/bin directory in that field , I tried to do this, but the result is the same. And all because it's the same file with this content

#!/usr/bin/env node

var cli = require('../lib/cli');
cli.interpret();
th3coop commented 4 years ago

@Nemial what IS that file? It looks like it's loading node cli. How are you using it? What did you change in the configuration dialog?

I also note that you are on Linux, I thought you were on Windows for some reason. There should be an executable file in your node_modules folder for js-beautify. What does which js-beautify return?

Nemial commented 4 years ago

This is a file from a folder /usr/lib/node_modules/js-beautify/js/bin/. I use it to format my code(remove extra spaces, indents, and align everything). Yes I find on Linux Slackware Current. When used(in the options, specify use when saving a file), it gives

-- EXCEPTION START --
[Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [koIFormatter.format]"  nsresult: "0x80004005 (NS_ERROR_FAILURE)"  location: "JS frame :: chrome://komodo/content/formatters/formatters.js :: _formatViewWithFormatterAndContext :: line 135"  data: no]
+ toString (function) 3 lines
+ message (string) 'Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [koIFormatter.format]'
+ result (number) 2147500037
+ name (string) 'NS_ERROR_FAILURE'
+ filename (string) 'chrome://komodo/content/formatters/formatters.js'
+ lineNumber (number) 135
+ columnNumber (number) 0
+ inner (object) null
| + data (object) null
| + stack (string) '_formatViewWithFormatterAndContext@chrome://komodo/content/formatters/formatters.js:135:16
formatVie'...982 chars
+ location (object) JS frame :: chrome://komodo/content/formatters/formatters.js :: _formatViewWithFormatterAndContext :: line 135
| + QueryInterface (function) 3 lines
| + language (number) 2
| + languageName (string) 'JavaScript'
| + filename (string) 'chrome://komodo/content/formatters/formatters.js'
| + name (string) '_formatViewWithFormatterAndContext'
| + lineNumber (number) 135
| + columnNumber (number) 16
| + sourceLine (string) ''
| + caller (object) JS frame :: chrome://komodo/content/formatters/formatters.js :: formatViewUsingConfig :: line 870
| + formattedStack (string) '_formatViewWithFormatterAndContext@chrome://komodo/content/formatters/formatters.js:135:16
formatVie'...982 chars
| + stack
    _formatViewWithFormatterAndContext@chrome://komodo/content/formatters/formatters.js:135:16
    formatViewUsingConfig@chrome://komodo/content/formatters/formatters.js:870:16
    formatViewUsingConfigUuid@chrome://komodo/content/formatters/formatters.js:939:0
    @chrome://komodo/content/formatters/formatters.js:991:16
    _doSave@vieweditor:1327:0
    save@vieweditor:1588:27
    viewManager.prototype.do_cmd_save@chrome://komodo/content/views.js:1539:4
    xtk.Controller.prototype.doCommand@chrome://xtk/content/controller.js:61:8
    command_doCommand@chrome://komodo/content/library/commands.js:239:0
    command_doCommandAsync@chrome://komodo/content/library/commands.js:191:0
    @chrome://komodo/content/keybindings/keybindings.js line 2603 > eval:1:0
    this.Manager.prototype.evalCommand@chrome://komodo/content/keybindings/keybindings.js:2603:22
    this.Manager.prototype.keypressHandler@chrome://komodo/content/keybindings/keybindings.js:2774:16
    gKeyHandler@chrome://komodo/content/keybindings/keybindings.js:2658:4
-- EXCEPTION END --
Nemial commented 4 years ago

However, if you use js-beautify from a regular linux terminal, everything works. It does not work in the IDE

th3coop commented 4 years ago

@Nemial try removing the -o. Komodo should handle the input and output file options.

Nemial commented 4 years ago

Oh, thank you. It's finally working

th3coop commented 4 years ago

Oh awesome! Ok cool. Thanks for your patience @Nemial !