Reputation: 14016
I have been using Atom's atom-beautify plugin for quite some time now, but all of a sudden since yesterday, whenever I try to beautify/save my C code I got the error:
Uncaught TypeError: Cannot read property 'setScrollTop' of null
screenshot below:
and sometimes I get a different error:
the issue has been reported in the github repository multiple times (e.g. this one) with no proper solutions so far. That's why I'm asking for help here instead! I did some research and it seems it is a Javascript/JSON issue hence the tags. Sorry if they are not relevant, as a C programer I don't know that much about JavaScript and JSON.
I'm using atom editor on my mac OS X elcappitan but others have also reported the same issue on windows and linux. I would appreciate if you could help me understand why this happens and how I can fix this.
Upvotes: 1
Views: 1067
Reputation: 420
It looks like the view?.setScrollTop
can't handle and unknown value, I'll submit a pull request.
These are the lines causing the problem:
setScrollTop = (editor, value) ->
view = atom.views.getView(editor)
view ?.setScrollTop value
This is a possible solution:
setScrollTop = (editor, value) ->
view = atom.views.getView(editor)
view ?.setScrollTop value ?0
Upvotes: 0
Reputation: 420
Simple answers:
use a different package for now;
and unless you're fluent in JavaScript/CoffeeScript, I wouldn't change any of the package contents.
Explanations:
JSON is a straight-forward key:value pairing system, such as {"name":"Donald Duck"}
.
That error is in JavaScript (obviously), because Atom uses CoffeeScript, JavaScript, CSS and HTML to make their editor--and since you're using a plugin, I'm pretty sure the plugin maker set one of the values to an unintentional null
when trying to find an HTML element that it relies on.
So--the plugin is looking for an HTML element (via CoffeeScript [JavaScript]) that doesn't exist, but can be fixed manually (if you're fluent in Coffee).
This issue is also in Brackets, and the only solution was to use an entirely different package.
Upvotes: 1