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

web-beautify-js erases whole buffer #6034

Closed
neonsamurai opened this issue May 12, 2016 · 10 comments
Closed

web-beautify-js erases whole buffer #6034

neonsamurai opened this issue May 12, 2016 · 10 comments
Labels

Comments

@neonsamurai
Copy link

Description

When invoking 'web-beautify-js' in JSON mode, for example by pressing , = or SPC m = the whole buffer is erased on many JSON files.

Reproduction guide

  • Start Emacs
  • rename attached file 'mtc.simple.json.txt. to 'mtc.simple.json'
  • open attached file 'mtc.simple.json'
  • invoke 'web-beautify-json' (press SPC m = or , =)

Observed behaviour:
The buffer is erased, resulting in an empty buffer.

Expected behaviour:
The JSON in the buffer should be pretty printed.

Notes
When invoking 'json-mode-beautify' by pressing C-c C-f (while JSON mode is active) the buffer is pretty printed as expected.

System Info

  • OS: darwin
  • Emacs: 24.5.1
  • Spacemacs: 0.105.19
  • Spacemacs branch: master (rev. 5f26b82)
  • Graphic display: t
  • Distribution: spacemacs
  • Editing style: vim
  • Completion: helm
  • Layers:
(auto-completion better-defaults emacs-lisp osx git github markdown org restclient
                 (shell :variables shell-default-height 30 shell-default-position 'bottom)
                 spell-checking syntax-checking version-control elixir elm html javascript sql yaml react)

Backtrace

web-beautify-format-region: Wrong type argument: numberp, "Abort trap: 6"
Suspicious state from syntax checker json-python-json: Checker json-python-json returned non-zero exit code 1, but no errors from output: No JSON object could be decoded

Checker definition probably flawed.

mtc.simple.json.txt

@cpaulik
Copy link
Contributor

cpaulik commented May 12, 2016

I can't reproduce that. Do you have the latest version of the packages? Have you tried calling js-beautify on the file in your terminal?

@codahale
Copy link

Probably related to this issue: nodejs/node#6563.

@neonsamurai
Copy link
Author

neonsamurai commented May 12, 2016

js-beautify errors when invoking like this:

$ js-beautify -f mtc.simple.json
TypeError: Path must be a string. Received undefined
    at assertPath (path.js:7:11)
    at Object.dirname (path.js:1324:5)
    at Object.processInputSync (/usr/local/lib/node_modules/js-beautify/js/lib/cli.js:311:24)
    at Array.forEach (native)
    at Object.exports.interpret (/usr/local/lib/node_modules/js-beautify/js/lib/cli.js:199:19)
    at Object.<anonymous> (/usr/local/lib/node_modules/js-beautify/js/bin/js-beautify.js:4:5)
    at Module._compile (module.js:541:32)
    at Object.Module._extensions..js (module.js:550:10)
    at Module.load (module.js:456:32)
    at tryModuleLoad (module.js:415:12)
Run `js-beautify -h` for help.

But works when piping the file from stdin:

js-beautify < mtc.simple.json
{
    "PA": "MAN Truck & Bus AG, 80995, M\u00fcnchen, DE",
    "GT": "Abschrankungskonstruktion f\u00fcr einen Rollstuhlplatz in einem Fahrzeug",
    "AD": "20131009",
    "MC": [
        "A61G",
        "A61G0003",
        "A61G000308"
    ],
    "DE": "102013016746",
    "AN": "DE102013016746",
    "PC": "DE",
    "AB": "<p num=\"0000\">Die Erfindung betrifft eine Abschrankungskonstruktion (100) f\u00fcr einen Rollstuhlplatz in einem Fahrzeug, vorzugsweise in einem Omnibus. Die Abschrankungskonstruktion (100) umfasst ein Oberteil (1) und ein Unterteil (2) zur Montage an das Fahrzeug und eine mit dem Oberteil (1) und dem Unterteil (2) verbundene Abschrankungseinrichtung (3). Die Abschrankungskonstruktion (100) zeichnet sich insbesondere dadurch aus, dass die Abschrankungseinrichtung (3) relativ zu dem Oberteil (1) und dem Unterteil (2) translatorisch in eine eingefahrene Stellung und eine oder mehrere ausgefahrene Stellungen verschiebbar ist.<\/p><p num=\"\"><de-figure num=\"0\"><\/de-figure><\/p>",
    "IN": [
        "Kittel, Ralf, 80939, M\u00fcnchen, DE",
        "Schmerbeck, Franz, 94522, Wallersdorf, DE"
    ],
    "IC": [
        "A61G",
        "A61G0003",
        "A61G000308"
    ],
    "KI": "A1",
    "DP": "20150409"
}

Hope that helps.

@leohxj
Copy link

leohxj commented Dec 22, 2016

What's the progress about this issue?
I am using the lastest spacemacs dev branch on Windows 7.
When I run SPC m = on web-mode, it erases whole buffer too...

@d12frosted
Copy link
Collaborator

Looks like an upstream issue to me. Especially thanks to @neonsamurai's comment.

@neonsamurai
Copy link
Author

neonsamurai commented Dec 23, 2016 via email

@leohxj
Copy link

leohxj commented Dec 23, 2016

@neonsamurai
what means an upstream issue?
Should I combine some code?

@neonsamurai
Copy link
Author

neonsamurai commented Dec 23, 2016 via email

@leohxj
Copy link

leohxj commented Dec 25, 2016

@neonsamurai
Ok, it means the problem may be causing by node or js-beautify module, right?
How do you fixed this issue?

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please let us know if this issue is still valid!

@github-actions github-actions bot added the stale marked as a stale issue/pr (usually by a bot) label Feb 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants